12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- /** @format */
- import {Data, Mgr} from '../GameControl'
- import {ccUtils} from '../utils/ccUtils'
- import {UI} from '../enums/UI'
- import {GAME_TYPE, GOODS} from '../enums/Enum'
- import {IGameResult, IStageChoose} from '../interface/UIInterface'
- /** @format */
- export class GameManager {
- async gotoGame() {
- Data.game.gameBundle = await ccUtils.getBundleAsync('game')
- Mgr.ui.show(UI.GameLoadingUI)
- }
- initNormal() {}
- initElite() {}
- async startNormalGame(stageID: number, currentRound: number, currentCost: number) {
- let isFightStage = stageID == Math.floor(currentRound / 100)
- Data.game.stageID = stageID
- Data.game.stageRound = isFightStage ? currentRound : stageID * 100 + 1
- //if (CC_DEV) Data.game.cost += 100
- Data.game.gameType = GAME_TYPE.normal
- Data.game.dropOut = null
- await this.gotoGame()
- }
- async startEliteGame(stageID: number) {
- Data.game.stageID = stageID
- Data.game.stageRound = Data.game.stageID * 100 + 1
- Data.game.gameType = GAME_TYPE.elite
- Data.game.dropOut = null
- await this.gotoGame()
- }
- exitGame(result?: IGameResult) {
- Mgr.ui.closeAll()
- Mgr.ui.show(UI.MainUI)
- let stageChooseArgs: IStageChoose = {gameType: Data.game.gameType}
- switch (Data.game.gameType) {
- case GAME_TYPE.normal:
- case GAME_TYPE.elite:
- Mgr.ui.show(UI.CurrencyUI, [GOODS.coin, GOODS.diamond, GOODS.fatigue])
- Mgr.ui.show(UI.StageChooseUI, stageChooseArgs)
- break
- }
- }
- }
|