| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 | import { _decorator, ProgressBar, } from 'cc';import { GameInfo } from '../../GameInfo';import { ModulerBase } from '../GameFrameWork/ModulerBase';const { ccclass, property } = _decorator;@ccclass('BattleSceneRight')export class BattleSceneRight extends ModulerBase {    //当前等级拥有的经验    private _curGradeExp: number = 10;    //当前等级升级所需经验    private _curGradeNeedExp: number = 100;    private _progressBar: ProgressBar = null;    protected onStart() {        this._grade(GameInfo.Instance.getGrade());        this._winNumber(GameInfo.Instance.getWin());        this._failNumber(GameInfo.Instance.getFail());        this._progressBar = this.getNode("_ProgressBar").getComponent(ProgressBar);        this._progressBar.progress = (this._curGradeExp / this._curGradeNeedExp);        this.onBtnClick("_btnArena", this._onBtnArenaClick);        this._exp(this._curGradeExp, this._curGradeNeedExp)    }    private _setProgress(addExp: number) {        this._curGradeExp += addExp;        if(this._curGradeExp >= this._curGradeNeedExp){            this._curGradeExp -= this._curGradeNeedExp;            this._curGradeNeedExp *= 2;            this._grade((GameInfo.Instance.getGrade() + 1));            this._exp(this._curGradeExp, this._curGradeNeedExp);            this._progressBar.progress = (this._curGradeExp / this._curGradeNeedExp);        }        this._exp(this._curGradeExp, this._curGradeNeedExp);        this._progressBar.progress = (this._curGradeExp / this._curGradeNeedExp);    }    private _onBtnArenaClick(){        this._setProgress(30);    }    private _exp(curExp: number, needExp: number){        this.getLabel("_exp").string = `${curExp}/${needExp}`;    }    //账号等级    private _grade(grade: number) {        this.getLabel("_grade").string = `${(grade)}`;    }    //获胜场数    private _winNumber(win: number) {        this.getLabel("_win").string = `${(GameInfo.Instance.getWin())}`;    }    //失败场数    private _failNumber(fail: number) {        this.getLabel("_fail").string = `${(GameInfo.Instance.getFail())}`;    }}
 |