/** @format */ import {UI} from '../enums/UI' import {BaseUI} from './BaseUI' import {Data, Mgr} from '../GameControl' import {ccUtils} from '../utils/ccUtils' import {observer, render, node, label, editBox, list} from '../mobx/observer' import {msgCmd} from '../proto/msg_cmd' import {ZumaConfig} from '../config/ZumaConfig' import {ZumaCore} from '../zuma/ZumaCore' import {ZumaRole} from '../zuma/ZumaRole' import FightCore from '../zuma/FightCore' import {GAME_PREFAB_TYPE, GAME_ROLE_TIP, GAME_TYPE, RELIC_EVENT_NTY} from '../enums/Enum' import {adventureEnd, dailyDungeonsEnd, relicEventSelect} from '../proto/game' import {IStageInfoConfig, StageInfoConfig} from '../config/StageInfoConfig' import {EliteInfoConfig, IEliteInfoConfig} from '../config/EliteInfoConfig' import {IReliclevelsConfig, ReliclevelsConfig} from '../config/ReliclevelsConfig' import {DailyConfig, IDailyConfig} from '../config/DailyConfig' import {IStageConfig, StageConfig} from '../config/StageConfig' import {EliteStageConfig, IEliteStageConfig} from '../config/EliteStageConfig' import {ChallengeConfig, IChallengeConfig} from '../config/ChallengeConfig' import {ICard} from '../interface/GlobalInterface' const {ccclass, property} = cc._decorator @ccclass @observer export class ZumaUI extends BaseUI { @node('zuma') zumaNode: cc.Node @node('fight') fightNode: cc.Node @node('pausePop') private pausePop: cc.Node zumaCore: ZumaCore fightCore: FightCore roundID: number activeBuff: number[] = [] onLoad() { this.zumaCore = this.zumaNode.getComponent(ZumaCore) this.fightCore = this.fightNode.getComponent(FightCore) } onShow(args, fromUI: number) { //Mgr.net.add(msgCmd.xxx, this, this.onXXXRsp) this.activeBuff.length = 0 let zumaRole = cc.find('role', this.zumaNode).getComponent(ZumaRole) this.zumaCore.init(zumaRole, this) this.fightCore.init(this) this.startFightRound() } onHide(): any { Mgr.event.removeAll(this) } //UI或者其他函数======================================= startFightRound() { Data.game.stageRound = 101 this.fightCore.resetGameWorld() //resetGameWorld需要一帧清理数据 this.scheduleOnce(() => { this.fightCore.startStageGame() }) } endFightRound(isWin: boolean) { this.fightCore.isStop = true if (isWin) { let hasNext = this.fightCore.getRoundCfg(true) if (!hasNext) { this.endGame(true) } else { this.startZuma() } } else { this.endGame(false) } } startZuma() { this.zumaCore.startGame() } endZuma() { this.fightCore.startNextRound() } addZumaBuff(buffID: number) { let index = this.activeBuff.indexOf(buffID) if (index < 0) { this.activeBuff.push(buffID) this.fightCore.addTeamBuff(buffID) } else { //当前直接BUFFID+1做升级处理 this.activeBuff[index] += 1 this.fightCore.addTeamBuff(this.activeBuff[index]) } } endGame(isWin) { if (this.fightCore.gameOver) return this.fightCore.gameOver = true if (this.fightCore.isTestScene) { this.startFightRound() } if (Data.game.gameType == GAME_TYPE.normal || Data.game.gameType == GAME_TYPE.elite) { let data = adventureEnd.create() data.win = isWin data.bossNum = this.fightCore.bossNum data.monsterNum = this.fightCore.monsterNum data.eliteNum = this.fightCore.eliteNum Mgr.net.send(msgCmd.cmd_adventure_end, data, true, true) } } //网络事件======================================= // onXXXRsp() {} //触发事件======================================= // @render // showRender() {} // 点击事件======================================= onBackClick() { this.hide() Mgr.ui.show(UI.MainUI) } onPauseClick() { this.fightCore.isStop = true this.pausePop.active = true //防止暂停UI多语言没有切换 // this.scheduleOnce(() => { // cc.director.pause() // }) } onContinueClick() { this.fightCore.isStop = false //cc.director.resume() this.pausePop.active = false } onQuitClick() { //cc.director.resume() this.pausePop.active = false Mgr.event.removeAll(this) this.endGame(false) Mgr.game.exitGame() } }