BattleSceneTop.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. }
  19. //金币数量
  20. private _gold(goldAmound: number) {
  21. this.getLabel("_gold").string = String(goldAmound);
  22. }
  23. //钻石数量
  24. private _diamond(diamondAmound: number) {
  25. this.getLabel("_diamond").string = String(diamondAmound);
  26. }
  27. //返回按钮
  28. private _btnReturn() {
  29. if (!GameMgr.Instance.getModuler(SelectTroops).showing()) {
  30. UIMgr.openUI("Start");
  31. } else {
  32. GameMgr.Instance.getModuler(SelectTroops).hide(false);
  33. }
  34. }
  35. battleMode(name: string) {
  36. this.getLabel("_battleMode").string = name;
  37. }
  38. }