|
@@ -5,6 +5,8 @@ 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';
|
|
|
+import { GlobalConfig } from '../../start/Config/GlobalConfig';
|
|
|
+import { AdvertMgr } from '../../core_tgx/base/ad/AdvertMgr';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('BattleUI')
|
|
@@ -62,12 +64,34 @@ export class BattleUI extends Component {
|
|
|
}
|
|
|
|
|
|
private onScreenShot(){
|
|
|
- EventDispatcher.instance.emit(GameEvent.EVENT_CAMERA_SCREENSHOT);
|
|
|
+ this.useAbility(
|
|
|
+ UserManager.instance.userModel.freeScreenShotCount,
|
|
|
+ (count) => UserManager.instance.reduceFreeScreenShotCount(count),
|
|
|
+ GameEvent.EVENT_CAMERA_SCREENSHOT
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
private onRadar(){
|
|
|
- console.log('侦擦');
|
|
|
- EventDispatcher.instance.emit(GameEvent.EVENT_CAMERA_SCREENSHOT_RADAR);
|
|
|
+ this.useAbility(
|
|
|
+ UserManager.instance.userModel.radarFreeCount,
|
|
|
+ (count) => UserManager.instance.reduceRadarFreeCount(count),
|
|
|
+ GameEvent.EVENT_CAMERA_SCREENSHOT_RADAR
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ private useAbility(freeCount: number,reduceFn: (count: number) => void,eventName: string) {
|
|
|
+ if(freeCount <= 0) {
|
|
|
+ if (!GlobalConfig.isDebug) {
|
|
|
+ AdvertMgr.instance.showReawardVideo(() => {
|
|
|
+ EventDispatcher.instance.emit(eventName);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ EventDispatcher.instance.emit(eventName);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ reduceFn(1);
|
|
|
+ EventDispatcher.instance.emit(eventName);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private unregisterListener() {
|