import { _decorator, Component, Label, Node } from 'cc'; import { UIBase, UIType } from '../GameFrameWork/UIBase'; import { GameInfo } from '../../GameInfo'; import { UIMgr } from '../../Frames/UIManager'; const { ccclass, property } = _decorator; @ccclass('BattleSceneTop') export class BattleSceneTop extends UIBase { protected onStart() { this.onBtnClick("_btnReturn", this._btnReturn); this._gold(GameInfo.Instance.getGold()); this._diamond(GameInfo.Instance.getDiamond()); this.onMsg("BattleMode", this._battleMode) } //金币数量 private _gold(goldAmound: number) { this.getNode("_gold").getComponent(Label).string = String(goldAmound); } //钻石数量 private _diamond(diamondAmound: number) { this.getNode("_diamond").getComponent(Label).string = String(diamondAmound); } //返回按钮 private _btnReturn() { if (!GameInfo.Instance.getBSTop) { UIMgr.closeUI("BattleScene_Left", false); UIMgr.closeUI("BattleScene_Right", false); this.hide(false); UIMgr.openUI("Start"); } else if (GameInfo.Instance.getBSTop) { UIMgr.closeUI("SelectTroops", false); this.getNode("_battleMode").getComponent(Label).string = "战斗模式"; UIMgr.openUI("BattleScene_Left", UIType.WIDGET); UIMgr.openUI("BattleScene_Right", UIType.WIDGET); } } private _battleMode() { this.getNode("_battleMode").getComponent(Label).string = "选择部队"; } }