BattleSceneRight.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { _decorator, ProgressBar, } from 'cc';
  2. import { GameInfo } from '../../GameInfo';
  3. import { ModulerBase } from '../GameFrameWork/ModulerBase';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('BattleSceneRight')
  6. export class BattleSceneRight extends ModulerBase {
  7. //当前等级拥有的经验
  8. private _curGradeExp: number = 10;
  9. //当前等级升级所需经验
  10. private _curGradeNeedExp: number = 100;
  11. private _progressBar: ProgressBar = null;
  12. protected onStart() {
  13. this._grade(GameInfo.Instance.getGrade());
  14. this._winNumber(GameInfo.Instance.getWin());
  15. this._failNumber(GameInfo.Instance.getFail());
  16. this._progressBar = this.getNode("_ProgressBar").getComponent(ProgressBar);
  17. this._progressBar.progress = (this._curGradeExp / this._curGradeNeedExp);
  18. this.onBtnClick("_btnArena", this._onBtnArenaClick);
  19. this._exp(this._curGradeExp, this._curGradeNeedExp)
  20. }
  21. private _setProgress(addExp: number) {
  22. this._curGradeExp += addExp;
  23. if(this._curGradeExp >= this._curGradeNeedExp){
  24. this._curGradeExp -= this._curGradeNeedExp;
  25. this._curGradeNeedExp *= 2;
  26. this._grade((GameInfo.Instance.getGrade() + 1));
  27. this._exp(this._curGradeExp, this._curGradeNeedExp);
  28. this._progressBar.progress = (this._curGradeExp / this._curGradeNeedExp);
  29. }
  30. this._exp(this._curGradeExp, this._curGradeNeedExp);
  31. this._progressBar.progress = (this._curGradeExp / this._curGradeNeedExp);
  32. }
  33. private _onBtnArenaClick(){
  34. this._setProgress(30);
  35. }
  36. private _exp(curExp: number, needExp: number){
  37. this.getLabel("_exp").string = `${curExp}/${needExp}`;
  38. }
  39. //账号等级
  40. private _grade(grade: number) {
  41. this.getLabel("_grade").string = `${(grade)}`;
  42. }
  43. //获胜场数
  44. private _winNumber(win: number) {
  45. this.getLabel("_win").string = `${(GameInfo.Instance.getWin())}`;
  46. }
  47. //失败场数
  48. private _failNumber(fail: number) {
  49. this.getLabel("_fail").string = `${(GameInfo.Instance.getFail())}`;
  50. }
  51. }