PropsAction.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. import { Props3Action } from './Props3Action';
  3. import { Props1Action } from './Props1Action';
  4. import { AudioMgr } from './AudioMgr';
  5. import { Clips } from './Enums';
  6. import { Props2Action } from './Props2Action';
  7. import { BasePage } from './BasePage';
  8. import { Props4Action } from './Props4Action';
  9. import { CatAction } from './CatAction';
  10. import { Global } from './Global';
  11. const { ccclass, property } = _decorator;
  12. @ccclass('PropsAction')
  13. export class PropsAction extends BasePage {
  14. @property(Props3Action)
  15. props3_Action: Props3Action = null;
  16. @property(Props1Action)
  17. props1_Action: Props1Action = null;
  18. @property(Props2Action)
  19. props2_Action: Props2Action = null;
  20. @property(Props4Action)
  21. props4_Action: Props4Action = null;
  22. @property(Label)
  23. coins_label: Label = null;
  24. start() {
  25. super.start();
  26. }
  27. update(deltaTime: number) {
  28. }
  29. /**
  30. * show menu
  31. * @param btn_num
  32. */
  33. open(btn_num: number = 0) {
  34. super.open();
  35. this.set_child_active_false();
  36. switch (btn_num) {
  37. case 1:
  38. this.props1_Action.node.active = true;
  39. this.props1_Action.open();
  40. break;
  41. case 2:
  42. this.props2_Action.node.active = true;
  43. this.props2_Action.open();
  44. break;
  45. case 3:
  46. this.props3_Action.node.active = true;
  47. this.props3_Action.open();
  48. break;
  49. case 4:
  50. this.props4_Action.node.active = true;
  51. this.props4_Action.open();
  52. break;
  53. }
  54. this.coins_label.string = Global.cur_coins+"";
  55. }
  56. show_box(cat_action:CatAction){
  57. this.open(4);
  58. this.props4_Action.show_box(cat_action);
  59. }
  60. private set_child_active_false() {
  61. this.props1_Action.node.active = false;
  62. this.props2_Action.node.active = false;
  63. this.props3_Action.node.active = false;
  64. this.props4_Action.node.active = false;
  65. }
  66. close() {
  67. this.set_child_active_false();
  68. super.close();
  69. }
  70. }