BattleSceneTop.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. import { UIBase, UIType } from '../GameFrameWork/UIBase';
  3. import { GameInfo } from '../../GameInfo';
  4. import { UIMgr } from '../../Frames/UIManager';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('BattleSceneTop')
  7. export class BattleSceneTop extends UIBase {
  8. protected onStart() {
  9. this.onBtnClick("_btnReturn", this._btnReturn);
  10. this._gold(GameInfo.Instance.getGold());
  11. this._diamond(GameInfo.Instance.getDiamond());
  12. this.onMsg("BattleMode", this._battleMode)
  13. }
  14. //金币数量
  15. private _gold(goldAmound: number) {
  16. this.getNode("_gold").getComponent(Label).string = String(goldAmound);
  17. }
  18. //钻石数量
  19. private _diamond(diamondAmound: number) {
  20. this.getNode("_diamond").getComponent(Label).string = String(diamondAmound);
  21. }
  22. //返回按钮
  23. private _btnReturn() {
  24. if (!GameInfo.Instance.getBSTop) {
  25. UIMgr.closeUI("BattleScene_Left", false);
  26. UIMgr.closeUI("BattleScene_Right", false);
  27. this.hide(false);
  28. UIMgr.openUI("Start");
  29. }
  30. else if (GameInfo.Instance.getBSTop) {
  31. UIMgr.closeUI("SelectTroops", false);
  32. this.getNode("_battleMode").getComponent(Label).string = "战斗模式";
  33. UIMgr.openUI("BattleScene_Left", UIType.WIDGET);
  34. UIMgr.openUI("BattleScene_Right", UIType.WIDGET);
  35. }
  36. }
  37. private _battleMode() {
  38. this.getNode("_battleMode").getComponent(Label).string = "选择部队";
  39. }
  40. }