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';
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("战斗模式");
        SelectTroops
        //this.onMsg("BattleMode", this._battleMode)
    }
    protected start(): void {
        
    }
    //金币数量
    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;
    }
}


