import { utils } from "../../common-plugin/Scripts/Utils"; import { cocosz } from "../Framework/CocosZ"; import Msg from "../Framework/Msg"; import AESUtil from "../AESUtil" import ATSDK from "../AnyThinkAds/ATJSSDK"; import ATRewardedVideoSDK from "../AnyThinkAds/ATRewardedVideoJSSDK"; import AAJS2 from "../ATAndroidJS2"; import GlobalManager from '../GlobalManager'; // @ts-ignore const i18n = require('LanguageData'); const { ccclass, property } = cc._decorator; @ccclass export default class NewClass extends cc.Component { @property(cc.Node) btnAD: cc.Node = null; @property(cc.Node) btnSkip: cc.Node = null; adKey: string = "zh_ad_type"; start() { console.log('zh:uiadpanel start ') if (cocosz.isADON) { this.node.scale = 0; cc.tween(this.node).to(0.3, { scale: 1 }, { easing: "backOut" }).start(); utils.SendEvent("页面-" + (this.isDiamond ? "钻石" : "金币")); } else { this.node.destroy(); } this.initAdForPage(); } initAdForPage() { if (cc.sys.os === cc.sys.OS_ANDROID) { let deviceId = AAJS2.getDeviceUserId(); console.log("zh:checkstatus:", ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementId())); var setting = {}; setting[ATRewardedVideoSDK.userIdKey] = deviceId; ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting); } } isDiamond: boolean = false; setDiamond() { this.isDiamond = true; this.node.getChildByName("bg").active = false; this.node.getChildByName("bg1").active = true; } watchAD() { utils.SendEvent(`视频-${this.isDiamond ? "钻石购买" : "金币购买"}-播放`) // 注册方法 , this.ClickClose.bind(this)); GlobalManager.getInstance().registerMethod('event_UIADPanel_forAd', this.event_UIADPanel_forAd.bind(this)); // cc.sys.localStorage.setItem(this.adKey, 'qianDao_dblq');// if (ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())) { console.log('zh:AD ready for idx2') ATRewardedVideoSDK.showAd(AAJS2.getPlacementId()); } else { console.log('zh:AD not ready for idx2') this.event_UIADPanel_forAd(); } if (2 > 1) { return;//下面是原始的代码 } cocosz.watchAD(() => { utils.SendEvent(`视频-${this.isDiamond ? "钻石购买" : "金币购买"}-成功`) if (this.isDiamond) { let num = cocosz.isDeBug ? 10000 : 200; cocosz.dataMgr.DiamondCount += num; Msg.Show(i18n.t("msg.gxhdzs") + num);//恭喜获得钻石 } else { let num = cocosz.isDeBug ? 10000 : 500; cocosz.dataMgr.CoinCount += num; Msg.Show(i18n.t("msg.gxhdjb") + num);//恭喜获得金币 } this.node.destroy(); }, () => { utils.SendEvent(`视频-${this.isDiamond ? "钻石购买" : "金币购买"}-失败`) }) } //zh: event_UIADPanel_forAd(){ console.log('zh:event_UIADPanel_forAd 被触发') if (this.isDiamond) { let num = cocosz.isDeBug ? 10000 : 200; cocosz.dataMgr.DiamondCount += num; Msg.Show(i18n.t("msg.gxhdzs") + num);//恭喜获得钻石 } else { let num = cocosz.isDeBug ? 10000 : 500; cocosz.dataMgr.CoinCount += num; Msg.Show(i18n.t("msg.gxhdjb") + num);//恭喜获得金币 } this.node.destroy(); } exit() { cocosz.audioMgr.playBtnEffect(); this.node.destroy(); } }