1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import { _decorator, } from 'cc';
- import { GameInfo } from '../../GameInfo';
- import { UIMgr } from '../../Frames/UIManager';
- import { ModulerBase } from '../GameFrameWork/ModulerBase';
- import { GameMgr } from '../GameFrameWork/GameMgr';
- import { SelectTroops } from './SelectTroops';
- import { messageMgr } from '../../Frames/MessageMgr';
- const { ccclass, property } = _decorator;
- @ccclass('BattleSceneTop')
- export class BattleSceneTop extends ModulerBase {
- protected onStart() {
- this.onBtnClick("_btnReturn", this._btnReturn);
- this._gold(GameInfo.Instance.getGold());
- this._diamond(GameInfo.Instance.getDiamond());
- this.battleMode("战斗模式");
- messageMgr.addEvent("reduceGold", this._gold, this);
- messageMgr.addEvent("reduceDiamond", this._diamond, this);
- if (GameInfo.Instance.getGameOverReward()?.size != 0) {
- this._gold(GameInfo.Instance.getGameOverReward().get("GameOverRewardGold"));
- this._diamond(GameInfo.Instance.getGameOverReward().get("GameOverRewardDia"));
- }
- }
- //金币数量
- private _gold(goldAmound: number) {
- this.getLabel("_gold").string = String(goldAmound);
- }
- //钻石数量
- private _diamond(diamondAmound: number) {
- this.getLabel("_diamond").string = String(diamondAmound);
- }
- //返回按钮
- private _btnReturn() {
- if (!GameMgr.Instance.getModuler(SelectTroops).showing()) {
- UIMgr.openUI("Start");
- } else {
- GameMgr.Instance.getModuler(SelectTroops).hide(false);
- }
- }
- battleMode(name: string) {
- this.getLabel("_battleMode").string = name;
- }
- }
|