BattleSceneTop.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { _decorator, } from 'cc';
  2. import { GameInfo } from '../../GameInfo';
  3. import { UIMgr } from '../../Frames/UIManager';
  4. import { ModulerBase } from '../GameFrameWork/ModulerBase';
  5. import { GameMgr } from '../GameFrameWork/GameMgr';
  6. import { SelectTroops } from './SelectTroops';
  7. import { messageMgr } from '../../Frames/MessageMgr';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('BattleSceneTop')
  10. export class BattleSceneTop extends ModulerBase {
  11. protected onStart() {
  12. this.onBtnClick("_btnReturn", this._btnReturn);
  13. this._gold(GameInfo.Instance.getGold());
  14. this._diamond(GameInfo.Instance.getDiamond());
  15. this.battleMode("战斗模式");
  16. messageMgr.addEvent("reduceGold", this._gold, this);
  17. messageMgr.addEvent("reduceDiamond", this._diamond, this);
  18. if (GameInfo.Instance.getGameOverReward()?.size != 0) {
  19. this._gold(GameInfo.Instance.getGameOverReward().get("GameOverRewardGold"));
  20. this._diamond(GameInfo.Instance.getGameOverReward().get("GameOverRewardDia"));
  21. }
  22. }
  23. //金币数量
  24. _gold(goldAmound: number) {
  25. this.getLabel("_gold").string = String(goldAmound);
  26. }
  27. //钻石数量
  28. _diamond(diamondAmound: number) {
  29. this.getLabel("_diamond").string = String(diamondAmound);
  30. }
  31. //返回按钮
  32. private _btnReturn() {
  33. if (!GameMgr.Instance.getModuler(SelectTroops).showing()) {
  34. UIMgr.openUI("Start");
  35. } else {
  36. GameMgr.Instance.getModuler(SelectTroops).hide(false);
  37. }
  38. }
  39. battleMode(name: string) {
  40. this.getLabel("_battleMode").string = name;
  41. }
  42. }