import DataMgr from "../data/DataMgr"; import { EAdType } from "../data/Define"; import UIBase from "../fgui/core/UIBase"; import ui_UITry from "../fgui/res/game/ui_UITry"; import PlatMgr from "../game/PlatMgr"; import { xGame } from "../xGame"; import GlobalManager from "../utils/GlobalManager"; import JSBridgeUtils from "../utils/JSBridgeUtils"; export default class UITry extends UIBase { protected ui: ui_UITry; private closeTime = 0; private closeNum = 0; private skillUrl = xGame.common.skillIconList; public constructor() { super(); } protected onConstructor(): void { this.ui = ui_UITry.createInstance(); this.contentPane = this.ui; this.addUIClick(this.ui.myNode.cancelBtn, this.onCancel); this.addUIClick(this.ui.myNode.videoBtn, this.onTry); } public show(): void { super.show(); this.closeNum = 0; this.closeTime = 15; this.ui.t0.play(); PlatMgr.showRateBanner(); this.ui.myNode.txtTime.text = this.closeTime.toString(); Laya.timer.loop(1000, this, this.updateTime); // let iconStr = this.skillUrl[xGame.common.curPlayerSkillType]; this.ui.myNode.n29.skillicon.url = xGame.common.getGameIconUrl(iconStr); // xGame.common.gameMgr.gamePause = true; // } updateTime() { if (this.closeTime > 1) { this.closeTime--; this.ui.myNode.txtTime.text = this.closeTime.toString(); } else this.hide(); } public hide() { Laya.timer.clearAll(this); Moyu.showBannerAd(false); super.hide(); // xGame.common.gameMgr.gamePause = false; } onTry() { console.log('zh:qjff_AD_for_uitry') // GlobalManager.instance.registerMethod('xxxxx',this.xxxxx); // JSBridgeUtils.instance.showRewardAd('xxxxx'); if (JSBridgeUtils.instance.showRewardAd('qjff_AD_for_uitry')) { } else { console.log('zh:AD 失败,直接发放奖励') this.qjff_AD_for_uitry(); } // //试用 // Moyu.showVideoAd(() => { // let select = xGame.common.curPlayerSkillType // DataMgr.gameData.trySkill = select; //当前试用技能ID // DataMgr.gameData.tryTime = Laya.timer.currTimer + 300000; // DataMgr.saveGameData(); // DataMgr.setBigSkill(select, 1); // xGame.showTip("Trial Successful");//试用成功 // this.hide(); // }, EAdType.try); } public qjff_AD_for_uitry() { let select = xGame.common.curPlayerSkillType DataMgr.gameData.trySkill = select; //当前试用技能ID DataMgr.gameData.tryTime = Laya.timer.currTimer + 300000; DataMgr.saveGameData(); DataMgr.setBigSkill(select, 1); xGame.showTip("Trial Successful");//试用成功 this.hide(); } onCancel() { if (this.closeNum > 0) { this.closeNum--; if (this.closeNum < 2) this.hide(); return; } else if (PlatMgr.getRand() < PlatMgr.tryVideoRate) { this.onTry(); } else if (PlatMgr.getRand() < PlatMgr.tryClose3Rate) { this.closeNum = 3; } else this.hide(); } } UITry.uiName = "UITry";