import { _decorator, Component, Label, Node, Sprite } from 'cc';
import { UIBase } from '../GameFrameWork/UIBase';
import { UIMgr } from '../../Frames/UIManager';
import { resMgr } from '../../Frames/ResourcesMgr';
import { GameInfo } from '../../GameInfo';
const { ccclass, property } = _decorator;

@ccclass('BattleSceneSelect')
export class BattleSceneSelect extends UIBase {
    protected onStart() {
        this.onBtnClick("_btnReturn", this._btnReturn);
        this._curLv(GameInfo.Instance.getCurlv());
        this._winNumber(GameInfo.Instance.getWin());
        this._failNumber(GameInfo.Instance.getFail());
        this._gold(GameInfo.Instance.getGold());
        this._diamond(GameInfo.Instance.getDiamond());
        this._grade(GameInfo.Instance.getGrade());
    }

    //当前关卡
    private _curLv(lv: number){
        this.getNode("_curLv").getComponent(Sprite).spriteFrame =
         resMgr.getSpriteFrame("font_0" + String(48 + lv));
    }

    //获胜场数
    private _winNumber(win: number) {
        this.getNode("_win").getComponent(Sprite).spriteFrame =
        resMgr.getSpriteFrame("font_0" + String(48 + win));
    }

    //失败场数
    private _failNumber(fail: number){
        this.getNode("_fail").getComponent(Sprite).spriteFrame = 
        resMgr.getSpriteFrame("font_0" + String(48 + fail));
    }

    //金币数量
    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 _grade(grade: number){
        this.getNode("_grade").getComponent(Label).string = String(grade);
    }

    //返回按钮
    private _btnReturn() {
        this.hide(false);
        UIMgr.openUI("Start");
    }

}


