MainItem.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { _decorator, Component, Enum, Node } from 'cc';
  2. import { Mode, ModeName } from '../enum/Mode';
  3. import { GameMgr } from '../manager/GameMgr';
  4. import { TransMgr } from '../manager/TransMgr';
  5. import { UIMgr } from '../manager/UIMgr';
  6. import { UI } from '../enum/UI';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('UIItem/MainItem')
  9. export class MainItem extends Component {
  10. @property(Node)
  11. private tip: Node = null
  12. @property({ type: Enum(Mode) })
  13. public mode: Mode = Mode.tp
  14. private btnStart: Node = null
  15. private btnUnlock: Node = null
  16. protected onLoad(): void {
  17. this.btnStart = this.node.getChildByName('BtnStart')
  18. this.btnUnlock = this.node.getChildByName('BtnUnlock')
  19. }
  20. protected start(): void {
  21. this.updateState()
  22. }
  23. private updateState(): void {
  24. this.tip.active = false
  25. this.btnUnlock.active = false
  26. }
  27. protected async onBtnStartClick() {
  28. await TransMgr.Inst.fadeIn()
  29. TransMgr.Inst.fadeOut()
  30. UIMgr.close(UI.Main)
  31. GameMgr.mode = this.mode
  32. GameMgr.startGame()
  33. }
  34. protected onBtnUnlockClick(): void {
  35. GameMgr.unlockMode(this.mode)
  36. this.updateState()
  37. }
  38. }