GameManager.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /** @format */
  2. import {Data, Mgr} from '../GameControl'
  3. import {ccUtils} from '../utils/ccUtils'
  4. import {UI} from '../enums/UI'
  5. import {GAME_TYPE, GOODS} from '../enums/Enum'
  6. import {IGameResult, IStageChoose} from '../interface/UIInterface'
  7. /** @format */
  8. export class GameManager {
  9. async gotoGame() {
  10. Data.game.gameBundle = await ccUtils.getBundleAsync('game')
  11. Mgr.ui.show(UI.GameLoadingUI)
  12. }
  13. initNormal() {}
  14. initElite() {}
  15. async startNormalGame(stageID: number, currentRound: number, currentCost: number) {
  16. let isFightStage = stageID == Math.floor(currentRound / 100)
  17. Data.game.stageID = stageID
  18. Data.game.stageRound = isFightStage ? currentRound : stageID * 100 + 1
  19. //if (CC_DEV) Data.game.cost += 100
  20. Data.game.gameType = GAME_TYPE.normal
  21. Data.game.dropOut = null
  22. await this.gotoGame()
  23. }
  24. async startEliteGame(stageID: number) {
  25. Data.game.stageID = stageID
  26. Data.game.stageRound = Data.game.stageID * 100 + 1
  27. Data.game.gameType = GAME_TYPE.elite
  28. Data.game.dropOut = null
  29. await this.gotoGame()
  30. }
  31. exitGame(result?: IGameResult) {
  32. Mgr.ui.closeAll()
  33. Mgr.ui.show(UI.MainUI)
  34. }
  35. }