|
@@ -0,0 +1,61 @@
|
|
|
+import { _decorator, Component, Label, Node } from 'cc';
|
|
|
+import { UserManager } from './Manager/UserMgr';
|
|
|
+import { GameUtil } from './GameUtil';
|
|
|
+import { tgxUIMgr } from '../../core_tgx/tgx';
|
|
|
+import { UI_BattleGambit } from '../../scripts/UIDef';
|
|
|
+import { EventDispatcher } from '../../core_tgx/easy_ui_framework/EventDispatcher';
|
|
|
+import { GameEvent } from './Enum/GameEvent';
|
|
|
+const { ccclass, property } = _decorator;
|
|
|
+
|
|
|
+@ccclass('BattleUI')
|
|
|
+export class BattleUI extends Component {
|
|
|
+
|
|
|
+ @property(Node)
|
|
|
+ public renderAd: Node = null;
|
|
|
+ @property(Label)
|
|
|
+ public lbRenderFreeCount: Label = null;
|
|
|
+
|
|
|
+ @property(Node)
|
|
|
+ public radarAd: Node = null;
|
|
|
+ @property(Label)
|
|
|
+ public lbRadarFreeCount: Label = null;
|
|
|
+
|
|
|
+ protected onLoad(): void {
|
|
|
+ this.registerListener();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected onDestroy(): void {
|
|
|
+ this.unregisterListener();
|
|
|
+ }
|
|
|
+
|
|
|
+ start() {
|
|
|
+ this.updateBtnsCountUI();
|
|
|
+ }
|
|
|
+
|
|
|
+ private registerListener() {
|
|
|
+ EventDispatcher.instance.on(GameEvent.EVENT_REFRESH_PLAYER_INFO,this.updateBtnsCountUI,this);
|
|
|
+ }
|
|
|
+
|
|
|
+ private updateBtnsCountUI(){
|
|
|
+ const {radarFreeCount,freeScreenShotCount} = UserManager.instance.userModel;
|
|
|
+ this.lbRenderFreeCount.string = `${freeScreenShotCount}`;
|
|
|
+ this.lbRadarFreeCount.string = `${radarFreeCount}`;
|
|
|
+
|
|
|
+ this.renderAd.active = false; //默认隐藏
|
|
|
+ this.radarAd.active = false; //默认隐藏
|
|
|
+
|
|
|
+ if(radarFreeCount <= 0){
|
|
|
+ this.lbRadarFreeCount.string = '';
|
|
|
+ this.radarAd.active = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(freeScreenShotCount <= 0){
|
|
|
+ this.lbRenderFreeCount.string = '';
|
|
|
+ this.renderAd.active = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private unregisterListener() {
|
|
|
+ EventDispatcher.instance.off(GameEvent.EVENT_REFRESH_PLAYER_INFO,this.updateBtnsCountUI,this);
|
|
|
+ }
|
|
|
+}
|