BattleSceneTop.ts 1.7 KB

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