BattleSceneRight.ts 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 = (GameInfo.Instance.getCurGradeExp() / this._curGradeNeedExp);
  18. this.onBtnClick("_btnArena", this._onBtnArenaClick);
  19. this._exp(GameInfo.Instance.getCurGradeExp(), this._curGradeNeedExp);
  20. if (GameInfo.Instance.getGameOverReward()?.size != 0) {
  21. this._setProgress(GameInfo.Instance.getGameOverReward().get("Xp"));
  22. }
  23. }
  24. private _setProgress(addExp: number) {
  25. GameInfo.Instance.setCurGradeExp(addExp);
  26. if (GameInfo.Instance.getCurGradeExp() >= this._curGradeNeedExp) {
  27. GameInfo.Instance.setCurGradeExp(
  28. GameInfo.Instance.getCurGradeExp() - this._curGradeNeedExp);
  29. this._curGradeNeedExp *= 2;
  30. this._grade((GameInfo.Instance.getGrade() + 1));
  31. this._exp(GameInfo.Instance.getCurGradeExp(), this._curGradeNeedExp);
  32. this._progressBar.progress = (GameInfo.Instance.getCurGradeExp() / this._curGradeNeedExp);
  33. }
  34. this._exp(GameInfo.Instance.getCurGradeExp(), this._curGradeNeedExp);
  35. this._progressBar.progress = (GameInfo.Instance.getCurGradeExp() / this._curGradeNeedExp);
  36. // this._curGradeExp += addExp;
  37. // if(this._curGradeExp >= this._curGradeNeedExp){
  38. // this._curGradeExp -= this._curGradeNeedExp;
  39. // this._curGradeNeedExp *= 2;
  40. // this._grade((GameInfo.Instance.getGrade() + 1));
  41. // this._exp(this._curGradeExp, this._curGradeNeedExp);
  42. // this._progressBar.progress = (this._curGradeExp / this._curGradeNeedExp);
  43. // }
  44. // this._exp(this._curGradeExp, this._curGradeNeedExp);
  45. // this._progressBar.progress = (this._curGradeExp / this._curGradeNeedExp);
  46. }
  47. private _onBtnArenaClick() {
  48. //this._setProgress(30);
  49. }
  50. private _exp(curExp: number, needExp: number) {
  51. this.getLabel("_exp").string = `${curExp}/${needExp}`;
  52. }
  53. //账号等级
  54. private _grade(grade: number) {
  55. this.getLabel("_grade").string = `${(grade)}`;
  56. }
  57. //获胜场数
  58. private _winNumber(win: number) {
  59. this.getLabel("_win").string = `${(GameInfo.Instance.getWin())}`;
  60. }
  61. //失败场数
  62. private _failNumber(fail: number) {
  63. this.getLabel("_fail").string = `${(GameInfo.Instance.getFail())}`;
  64. }
  65. }