"use strict"; cc._RF.push(module, '3c952ZNRpBGRYo/tgGSVrLA', 'hallScene'); // Script/hallScene.ts "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); var BaseView_1 = require("../lightMVC/core/base/BaseView"); var SDK_1 = require("./sdk/SDK"); var hallSceneMediator_1 = require("./hallSceneMediator"); var App_1 = require("./Manager/App"); var SoundManager_1 = require("./Manager/SoundManager"); var TimeControl_1 = require("./TimeControl"); var ChooseLevelPanel_1 = require("./view/chooseLevel/ChooseLevelPanel"); var ChooseLevelPanelMediator_1 = require("./view/chooseLevel/ChooseLevelPanelMediator"); var ChooseSkinPanel_1 = require("./view/chooseSkin/ChooseSkinPanel"); var ChooseSkinPanelMediator_1 = require("./view/chooseSkin/ChooseSkinPanelMediator"); var InsufficientPanel_1 = require("./view/insufficientPanel/InsufficientPanel"); var InsufficientPanelMediator_1 = require("./view/insufficientPanel/InsufficientPanelMediator"); var MissionPanel_1 = require("./view/missionPanel/MissionPanel"); var MissionPanelMediator_1 = require("./view/missionPanel/MissionPanelMediator"); var SetNormalPanel_1 = require("./view/setNormal/SetNormalPanel"); var SetNormalPanelMediator_1 = require("./view/setNormal/SetNormalPanelMediator"); var ShopPanel_1 = require("./view/shopView/ShopPanel"); var ShopPanelMediator_1 = require("./view/shopView/ShopPanelMediator"); var TipPanel_1 = require("./view/tipPanel/TipPanel"); var TipPanelMediator_1 = require("./view/tipPanel/TipPanelMediator"); var AESUtil_1 = require("./AESUtil"); var ATJSSDK_1 = require("./AnyThinkAds/ATJSSDK"); var ATRewardedVideoJSSDK_1 = require("./AnyThinkAds/ATRewardedVideoJSSDK"); var ATAndroidJS2_1 = require("./ATAndroidJS2"); var GlobalManager_1 = require("./GlobalManager"); var ATInterstitialJSSDK_1 = require("./AnyThinkAds/ATInterstitialJSSDK"); var ATBannerJSSDK_1 = require("./AnyThinkAds/ATBannerJSSDK"); var ATAndroidJS2_2 = require("./ATAndroidJS2"); var Tag = 'zh:UIGame'; var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; var hallScene = /** @class */ (function (_super) { __extends(hallScene, _super); function hallScene() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.startGameBtn = null; _this.setNormalBtn = null; // @property(cc.Button) // public chooseSkinBtn: cc.Button = null; _this.missionBtn = null; // @property(cc.Button) // public btnVideo: cc.Button = null; // @property(cc.Button) // public btnShop: cc.Button = null; _this.btnLeft = null; _this.btnRight = null; _this.pageView = null; _this.labelTili = null; _this.physicalTime = null; _this.labelCoin = null; _this.labelDiamond = null; _this.loadSceneName = "gameScene"; _this.currientView = 0; _this.adState = false; _this.adKey = "zh_ad_type"; return _this; //#endregion } hallScene_1 = hallScene; Object.defineProperty(hallScene, "instance", { get: function () { return hallScene_1._instance; }, set: function (value) { hallScene_1._instance = value; }, enumerable: false, configurable: true }); hallScene.prototype.onLoad = function () { // cc.sys.localStorage.clear(); var _this = this; hallScene_1.instance = this; this.registerMediator(hallSceneMediator_1.default, this, "主界面"); SDK_1.default.Instance.showBanner(); this.initAd(); this.initAdForPage(); //GlobalManager.getInstance().registerMethod('initAdForPageInter', this.initAdForPageInter.bind(this)); this.initAdPageForBanner(); setTimeout(function () { _this.showBannerAd(); }, 100); this.initAdInster(); }; hallScene.prototype.showOrHidenBannerAd = function (boo) { var pid = ATAndroidJS2_1.default.getPlacementId2(ATAndroidJS2_2.AdType.Banner); if (boo) { ATBannerJSSDK_1.default.reShowAd(pid); } else { ATBannerJSSDK_1.default.hideAd(pid); } }; hallScene.prototype.showBannerAd = function () { var pid = ATAndroidJS2_1.default.getPlacementId2(ATAndroidJS2_2.AdType.Banner); var boo = ATBannerJSSDK_1.default.hasAdReady(pid); // ATBannerJSSDK.showAdInPosition(pid, ATBannerJSSDK.kATBannerAdShowingPositionTop); ATBannerJSSDK_1.default.showAdInPosition(pid, ATBannerJSSDK_1.default.kATBannerAdShowingPositionBottom); if (boo) { console.log('zh:showBannerAd AD OK SHOW....'); //ATBannerJSSDK.showAdInPosition(pid, ATBannerJSSDK.kATBannerAdShowingPositionBottom); //ATBannerJSSDK.showAdInPosition(pid, ATBannerJSSDK.kATBannerAdShowingPositionTop); } else { console.log('zh:showBannerAd AD 没有准备好'); } }; /** * AD播放完毕的事件处理 */ hallScene.prototype.handleCustomEvent = function () { console.log('zh:00收到发送的事件'); //let adKey = "zh_ad_type" var yxAdMark = cc.sys.localStorage.getItem("yxAdMark"); console.log('zh:onAdOverEve yxAdMarkAAAA =' + yxAdMark); var adKeyTemp = ''; //初始化一下,随便 switch (yxAdMark) { case 'callBack_btnReplay': //失败了重新尝试 console.log('zh:callBack_btnReplay '); GlobalManager_1.default.instance.callMethod('callBack_btnReplay'); break; case 'callBack_for_chouJiang': //抽奖callBack_for_chouJiang console.log('zh:callBack_for_chouJiang '); GlobalManager_1.default.instance.callMethod('callBack_for_chouJiang'); break; case 'callBackFor_successPanel': //成功的时候奖 console.log('zh:callBackFor_successPanel '); GlobalManager_1.default.instance.callMethod('callBackFor_successPanel'); break; case 'callBack_forGetJBei': console.log('zh:callBack_forGetJBei '); //点击了奖杯 GlobalManager_1.default.instance.callMethod('callBack_forGetJBei'); break; case 'callBack_gotoNextLevel': console.log('zh:callBack_gotoNextLevel '); // GlobalManager_1.default.instance.callMethod('callBack_gotoNextLevel'); break; case 'callBackFor_kaoJiao': console.log('zh:callBackFor_kaoJiao '); // var yxAdMark_index = cc.sys.localStorage.getItem("yxAdMark_index"); GlobalManager_1.default.instance.callMethod('callBackFor_kaoJiao', yxAdMark_index); cc.sys.localStorage.delete(yxAdMark_index); break; case 'callBack_for_tiLiAd': console.log('zh:callBack_for_tiLiAd '); //体力不足 GlobalManager_1.default.instance.callMethod('callBack_for_tiLiAd'); break; default: console.log('zh:未知的道具类型AD==' + yxAdMark); } cc.sys.localStorage.setItem(this.adKey, ''); cc.sys.localStorage.setItem(adKeyTemp, ''); console.log('zh:清理adKey '); }; hallScene.prototype.initAd = function () { if (cc.sys.os != cc.sys.OS_ANDROID) { return; } //let adKey = "zh_ad_type" cc.sys.localStorage.setItem(this.adKey, ""); var placementId = ATAndroidJS2_1.default.getPlacementId(); var deviceId = ATAndroidJS2_1.default.getDeviceUserId(); var setting = {}; setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId; ATRewardedVideoJSSDK_1.default.loadRewardedVideo(placementId, setting); //console.log('zh:bbb222') var customPlacementId = ""; if (cc.sys.os === cc.sys.OS_IOS) { customPlacementId = placementId; } else if (cc.sys.os === cc.sys.OS_ANDROID) { customPlacementId = placementId; } // 初始化SDK // ATSDK.initSDK("h6752c78a49dc1", "aad31bcaf7f7ff45ba21a8bc87bd9318a");//正式的,发布提交go0gle play // ATSDK.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83");//测试专用,可以显示广告 // ATSDK.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e");//这是打砖块的已经上架的 ATJSSDK_1.default.initSDK("h67161678d3fcf", "aa0e53109399d0c3a213140e896bdac07"); //正式的整理大师 // ATSDK.initSDK("h6752c78a49dc1", "aad31bcaf7f7ff45ba21a8bc87bd9318a");//货柜1 正式的,发布提交go0gle play ATJSSDK_1.default.setLogDebug(true); //zh:diy var GDPRLevel = ATJSSDK_1.default.getGDPRLevel(); // 针对欧盟地区初始化时做的处理,按需求打开,不在欧盟地区发布的不用使用。 ATJSSDK_1.default.getUserLocation(function (userLocation) { //如果处于欧盟地区且等级是UNKNOW时,就执行授权弹窗 if (userLocation === ATJSSDK_1.default.kATUserLocationInEU) { if (ATJSSDK_1.default.getGDPRLevel() === ATJSSDK_1.default.UNKNOWN) { ATJSSDK_1.default.showGDPRAuth(); } } }); ATRewardedVideoJSSDK_1.default.setAdListener(this); if (cc.sys.os === cc.sys.OS_ANDROID) { setTimeout(function () { var allInfo = ATAndroidJS2_1.default.allInfo(); ATJSSDK_1.default.printLog("zh:allInfo=" + allInfo); var key = "US2%*c3lv8sYkUe(!e-6g$E*RJg)dzn@"; var iv = "Jn0.aWsOu$y-Dbqb"; var data = { data: AESUtil_1.default.AESencrypt(allInfo, key, iv) }; ATJSSDK_1.default.printLog("zh:allInfo-jm=" + JSON.stringify(data)); console.log('zh:ad_allInfo', data); ATAndroidJS2_1.default.makePostRequestWithXhr(JSON.stringify(data)); }, 200); } }; hallScene.prototype.initAdForPage = function () { if (cc.sys.os === cc.sys.OS_ANDROID) { var deviceId = ATAndroidJS2_1.default.getDeviceUserId(); console.log("zh:checkstatus:", ATRewardedVideoJSSDK_1.default.checkAdStatus(ATAndroidJS2_1.default.getPlacementId())); var setting = {}; setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId; ATRewardedVideoJSSDK_1.default.loadRewardedVideo(ATAndroidJS2_1.default.getPlacementId(), setting); } }; hallScene.prototype.start = function () { this.startGameBtn.node.on(cc.Node.EventType.TOUCH_END, this.ClickStartGame, this); this.setNormalBtn.node.on(cc.Node.EventType.TOUCH_END, this.ClickSetNormal, this); this.btnLeft.node.on(cc.Node.EventType.TOUCH_END, this.ClickLeft, this); this.btnRight.node.on(cc.Node.EventType.TOUCH_END, this.ClickRight, this); // this.btnVideo.node.on(cc.Node.EventType.TOUCH_END, this.ClickAddTili, this); this.missionBtn.node.on(cc.Node.EventType.TOUCH_END, this.ClickOpenMission, this); // this.chooseSkinBtn.node.on(cc.Node.EventType.TOUCH_END, this.ClickChooseSkin, this); // this.btnShop.node.on(cc.Node.EventType.TOUCH_END, this.ClickShop, this); // console.log('----------', TimeControl.instance.currentTili); // App.DataManager.TimeCountJudge();//全局倒计时判断 // if (App.DataManager.TimeFlag) { // let data = { "isShow": true, 'timeStr': App.DataManager.TimeChange(TimeControl.instance.currentTimeCount) }; // this.TiliCountShow(data); // } this.ShowPhysicalValue(); this.ShowUserCoinValue(); this.ShowUserDiamondValue(); App_1.App.SoundManager.playBGM(SoundManager_1.SoundManager.hallBgm[0]); }; hallScene.prototype.ClickOpenMission = function () { // this.showInterAd("callBackFor_ClickOpenMission",false, () => this.callBackFor_ClickOpenMission()); App_1.App.Facade.popView(MissionPanelMediator_1.default, MissionPanel_1.default, "打开任务界面", false); }; hallScene.prototype.callBackFor_ClickOpenMission = function () { App_1.App.Facade.popView(MissionPanelMediator_1.default, MissionPanel_1.default, "打开任务界面", false); }; /** * 体力显示设置 */ hallScene.prototype.ShowPhysicalValue = function () { console.log('############', TimeControl_1.default.instance.currentTili); if (hallScene_1.instance.labelTili) { hallScene_1.instance.labelTili.string = TimeControl_1.default.instance.currentTili + "/" + TimeControl_1.default.instance.tiliMax; } }; // 显示玩家金币 hallScene.prototype.ShowUserCoinValue = function () { if (hallScene_1.instance.labelCoin) { hallScene_1.instance.labelCoin.string = App_1.App.DataManager.UserCoin.toString(); } }; // 钻石 hallScene.prototype.ShowUserDiamondValue = function () { if (hallScene_1.instance.labelDiamond) { hallScene_1.instance.labelDiamond.string = App_1.App.DataManager.UserDiamond.toString(); } }; /** * 体力倒计时显示设置 */ hallScene.prototype.TiliCountShow = function (data) { if (!this.physicalTime) return; this.physicalTime.node.active = data.isShow; if (data.timeStr) this.physicalTime.string = data.timeStr; }; /** * 开始游戏 */ hallScene.prototype.StartGame_111 = function (intoLevel) { var _this = this; console.log("aaa-大是大非-------intoLevel----------", intoLevel); App_1.App.DataManager.UpdateTili(TimeControl_1.default.instance.consumeTili, function (success) { App_1.App.DataManager.CurrentIntoLevel = intoLevel; App_1.App.DataManager.PlayLevel = App_1.App.DataManager.CurrentIntoLevel; App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_playLevel, App_1.App.DataManager.PlayLevel); if (success) App_1.App.Facade.runBundleScene("gameScene", _this.loadSceneName); else App_1.App.Facade.popView(InsufficientPanelMediator_1.default, InsufficientPanel_1.default, "1体力不足", false); }); }; /** * 开始游戏 */ hallScene.prototype.StartGame = function (intoLevel) { var _this = this; console.log("aaa-大是大非-------intoLevel----------", intoLevel); App_1.App.DataManager.UpdateTili(TimeControl_1.default.instance.consumeTili, function (success) { // 更新当前进入的关卡和播放关卡 App_1.App.DataManager.CurrentIntoLevel = intoLevel; App_1.App.DataManager.PlayLevel = App_1.App.DataManager.CurrentIntoLevel; // 保存当前播放关卡到本地存储 App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_playLevel, App_1.App.DataManager.PlayLevel); // 根据体力更新结果跳转场景或提示 if (success) { console.log("2"); App_1.App.Facade.runBundleScene("gameScene", _this.loadSceneName); } else { console.log("1"); App_1.App.Facade.popView(InsufficientPanelMediator_1.default, InsufficientPanel_1.default, "体力不足", false); } }); }; /** * 点击开始游戏按钮直接开始 */ hallScene.prototype.ClickStartGame = function () { if (this.pageView.getCurrentPageIndex() == 1) { App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "coming soon!", false); } else { App_1.App.Facade.popView(ChooseLevelPanelMediator_1.default, ChooseLevelPanel_1.default, "关卡选择", false); } }; /** * 点击观看视频加体力 */ hallScene.prototype.ClickAddTili = function () { var _this = this; console.log('点击观看视频加体力~'); SoundManager_1.SoundManager.getInstance().VideoStartStop(); SDK_1.default.Instance.showRewardVideo(function () { TimeControl_1.default.instance.currentTili = TimeControl_1.default.instance.tiliMax; _this.ShowPhysicalValue(); App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_Tili, TimeControl_1.default.instance.currentTili); SoundManager_1.SoundManager.getInstance().VideoEndOpen(); }, function () { SoundManager_1.SoundManager.getInstance().VideoEndOpen(); }, function () { SoundManager_1.SoundManager.getInstance().VideoEndOpen(); }); }; // 商城 hallScene.prototype.ClickShop = function () { App_1.App.Facade.popView(ShopPanelMediator_1.default, ShopPanel_1.default, "商城", false); }; /** * 打开关卡选择界面 */ hallScene.prototype.ClickChooseLevel = function () { App_1.App.Facade.popView(ChooseLevelPanelMediator_1.default, ChooseLevelPanel_1.default, "关卡选择", true); App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "aasdasdf", false); }; /** * 打开选择皮肤界面 */ hallScene.prototype.ClickChooseSkin = function () { App_1.App.Facade.popView(ChooseSkinPanelMediator_1.default, ChooseSkinPanel_1.default, "皮肤选择", false); }; /** * 打开设置界面 */ hallScene.prototype.ClickSetNormal = function () { App_1.App.Facade.popView(SetNormalPanelMediator_1.default, SetNormalPanel_1.default, "设置", false); }; hallScene.prototype.ClickLeft = function () { this.currientView = this.pageView.getCurrentPageIndex() == 0 ? 1 : 0; this.pageView.scrollToPage(this.currientView, 0.5); }; hallScene.prototype.ClickRight = function () { this.currientView = this.pageView.getCurrentPageIndex() == 0 ? 1 : 0; this.pageView.scrollToPage(this.currientView, 0.5); }; hallScene.prototype.onDisable = function () { this.startGameBtn.node.off(cc.Node.EventType.TOUCH_END, this.ClickStartGame, this); this.setNormalBtn.node.off(cc.Node.EventType.TOUCH_END, this.ClickSetNormal, this); this.btnLeft.node.off(cc.Node.EventType.TOUCH_END, this.ClickLeft, this); this.btnRight.node.off(cc.Node.EventType.TOUCH_END, this.ClickRight, this); this.missionBtn.node.off(cc.Node.EventType.TOUCH_END, this.ClickOpenMission, this); // this.btnVideo.node.off(cc.Node.EventType.TOUCH_END, this.ClickAddTili, this); // this.btnShop.node.off(cc.Node.EventType.TOUCH_END, this.ClickShop, this); // this.chooseSkinBtn.node.off(cc.Node.EventType.TOUCH_END, this.ClickChooseSkin, this); }; // update (dt) {} hallScene.prototype.onRewardedVideoAdLoaded = function (placementId) { ATJSSDK_1.default.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdLoaded(" + placementId + ")"); }; hallScene.prototype.onRewardedVideoAdFailed = function (placementId, errorInfo) { ATJSSDK_1.default.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdFailed(" + placementId + ", " + errorInfo + ")"); }; hallScene.prototype.onRewardedVideoAdPlayStart = function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayStart(" + placementId + ", " + callbackInfo + ")"); var deviceId = ATAndroidJS2_1.default.getDeviceUserId(); var setting = {}; setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId; ATRewardedVideoJSSDK_1.default.loadRewardedVideo(ATAndroidJS2_1.default.getPlacementId(), setting); }; hallScene.prototype.onRewardedVideoAdPlayEnd = function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayEnd(" + placementId + ", " + callbackInfo + ")"); console.log('zh: ad PlayEnd'); //this.node.emit("handleCustomEvent"); }; hallScene.prototype.onRewardedVideoAdPlayFailed = function (placementId, errorInfo, callbackInfo) { ATJSSDK_1.default.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayFailed(" + placementId + ", " + errorInfo + ", " + callbackInfo + ")"); }; hallScene.prototype.onRewardedVideoAdClosed = function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("zh:AnyThinkRewardedVideoDemo::AdClosed(" + placementId + ", " + callbackInfo + ")"); if (this.adState == true) { this.adState = false; console.log('zh: ad奖励OK,开始处理奖励'); this.handleCustomEvent(); } else { console.log('zh: ad奖励标识 NO OK '); } }; hallScene.prototype.onRewardedVideoAdPlayClicked = function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayClicked(" + placementId + ", " + callbackInfo + ")"); }; hallScene.prototype.onReward = function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("zh:AnyThinkRewardedVideoDemo::onReward(" + placementId + ", " + callbackInfo + ")"); console.log('zh:onReward AD奖励标志OK'); this.adState = true; }; //#region 插屏广告 /** * 显示插屏广告 * * @param adMarkForClose 插屏广告关闭后调用那个方法的具体指示标识 * @param checkClose 是否需要判断关闭事件,有的不需要,如果AD占用游戏时间则为true * @param callback 插屏广告关闭(加载失败\非ANDROID平台)的回调 */ hallScene.prototype.showInterAd = function (adMarkForClose, checkClose, callback) { if (cc.sys.os === cc.sys.OS_ANDROID) { cc.sys.localStorage.setItem("adMarkForClose", adMarkForClose); //关闭后,调用哪个方法的标识 //add判断插屏 开屏等 var pid_inter = ATAndroidJS2_1.default.getPlacementId2(ATAndroidJS2_2.AdType.Inter); var boo = ATInterstitialJSSDK_1.default.hasAdReady(pid_inter); if (boo) { // 暂停游戏 cc.director.pause(); console.log('zh:showInterAd AD OK'); ATInterstitialJSSDK_1.default.showAd(pid_inter); //因为跨脚本,所以使用全局注册函数调用,后来发现切换APP,导致ad close事件失效 if (!checkClose) { //如果不占用游戏时间 callback(); } } else { console.log('zh:showInterAd AD 没有准备好'); //GlobalManager.getInstance().callMethod('initAdForPageInter'); this.initAdForPageInter(); callback(); } } else { callback(); } }; //add判断插屏 开屏等,需要多次准备 //add判断插屏 开屏等,需要多次准备 hallScene.prototype.initAdForPageInter = function () { if (cc.sys.os === cc.sys.OS_ANDROID) { console.log('zh:skillBox.ts 开始准备AD .....'); var deviceId = ATAndroidJS2_1.default.getDeviceUserId(); var setting = {}; setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId; //add判断插屏 开屏等 var pid_inter = ATAndroidJS2_1.default.getPlacementId2(ATAndroidJS2_2.AdType.Inter); console.log("zh: pid_inter checkstatus:", ATInterstitialJSSDK_1.default.checkAdStatus(pid_inter)); ATInterstitialJSSDK_1.default.loadInterstitial(pid_inter, setting); } }; hallScene.prototype.initAdPageForBanner = function () { //v5.6.8新增 var setting = {}; var deviceId = ATAndroidJS2_1.default.getDeviceUserId(); setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId; // let fsw =screen.windowSize.width; // let fsw = cc.view.getFrameSize().width var fsw = cc.view.getFrameSize().width; setting[ATBannerJSSDK_1.default.kATBannerAdLoadingExtraBannerAdSizeStruct] = ATBannerJSSDK_1.default.createLoadAdSize(fsw, 150); //只针对Admob的自适应banner setting[ATBannerJSSDK_1.default.kATBannerAdAdaptiveWidth] = fsw; setting[ATBannerJSSDK_1.default.kATBannerAdAdaptiveOrientation] = ATBannerJSSDK_1.default.kATBannerAdAdaptiveOrientationCurrent; // setting[ATBannerJSSDK.kATBannerAdAdaptiveOrientation] = ATBannerJSSDK.kATBannerAdAdaptiveOrientationPortrait; // setting[ATBannerJSSDK.kATBannerAdAdaptiveOrientation] = ATBannerJSSDK.kATBannerAdAdaptiveOrientationLandscape; var pid = ATAndroidJS2_1.default.getPlacementId2(ATAndroidJS2_2.AdType.Banner); ATBannerJSSDK_1.default.loadBanner(pid, setting); var bannerListener = { //广告加载成功 onBannerAdLoaded: function (placementId) { ATJSSDK_1.default.printLog("AnyThinkBannerDemo::onBannerAdLoaded(" + placementId + ")"); }, //广告加载失败 onBannerAdLoadFail: function (placementId, errorInfo) { ATJSSDK_1.default.printLog("AnyThinkBannerDemo::onBannerAdLoadFail(" + placementId + ", " + errorInfo + ")"); this.initAdPageForBanner(); }, //广告展示成功 onBannerAdShow: function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("AnyThinkBannerDemo::onBannerAdShow(" + placementId + ", " + callbackInfo + ")"); }, //广告被点击 onBannerAdClick: function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("AnyThinkBannerDemo::onBannerAdClick(" + placementId + ", " + callbackInfo + ")"); }, //广告自动刷新成功 onBannerAdAutoRefresh: function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("AnyThinkBannerDemo::onBannerAdAutoRefresh(" + placementId + ", " + callbackInfo + ")"); }, //广告自动刷新失败 onBannerAdAutoRefreshFail: function (placementId, errorInfo) { ATJSSDK_1.default.printLog("AnyThinkBannerDemo::onBannerAdAutoRefreshFail(" + placementId + ", " + errorInfo + ")"); }, //广告关闭按钮被点击 onBannerAdCloseButtonTapped: function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("AnyThinkBannerDemo::onBannerAdCloseButtonTapped(" + placementId + ", " + callbackInfo + ")"); this.initAdPageForBanner(); } }; ATBannerJSSDK_1.default.setAdListener(bannerListener); console.log("zh:initAdPageForBanner listener over ..... "); }; hallScene.prototype.initAdInster = function () { var adKey = "adMarkForClose"; cc.sys.localStorage.setItem(adKey, ""); var deviceId = ATAndroidJS2_1.default.getDeviceUserId(); var setting = {}; setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId; var pid = ATAndroidJS2_1.default.getPlacementId2(ATAndroidJS2_2.AdType.Inter); var placementId = pid; setting[ATInterstitialJSSDK_1.default.UseRewardedVideoAsInterstitial] = false; //UseRewardedVideoAsInterstitial //setting[ATInterstitialJSSDK.UseRewardedVideoAsInterstitial] = true; ATInterstitialJSSDK_1.default.loadInterstitial(pid, setting); //v5.6.8以下 //ATInterstitialSDK.loadInterstitial(pid); var that = this; var interstitialListener = { //广告加载成功 onInterstitialAdLoaded: function (placementId) { ATJSSDK_1.default.printLog("AnyThinkInterstitialDemo::onInterstitialAdLoaded(" + placementId + ")"); }, //广告加载失败 onInterstitialAdLoadFail: function (placementId, errorInfo) { ATJSSDK_1.default.printLog("AnyThinkInterstitialDemo::onInterstitialAdLoadFail(" + placementId + ", " + errorInfo + ")"); }, //广告展示成功 onInterstitialAdShow: function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("AnyThinkInterstitialDemo::onInterstitialAdShow(" + placementId + ", " + callbackInfo + ")"); setTimeout(function () { that.initAdForPageInter(); }, 500); }, //广告视频开始播放,部分平台有此回调 onInterstitialAdStartPlayingVideo: function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("AnyThinkInterstitialDemo::onInterstitialAdStartPlayingVideo(" + placementId + ", " + callbackInfo + ")"); }, //广告视频播放结束,部分广告平台有此回调 onInterstitialAdEndPlayingVideo: function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("AnyThinkInterstitialDemo::onInterstitialAdEndPlayingVideo(" + placementId + ", " + callbackInfo + ")"); }, //广告视频播放失败,部分广告平台有此回调 onInterstitialAdFailedToPlayVideo: function (placementId, errorInfo) { ATJSSDK_1.default.printLog("AnyThinkInterstitialDemo::onInterstitialAdFailedToPlayVideo(" + placementId + ", " + errorInfo + ")"); }, //广告展示失败 onInterstitialAdFailedToShow: function (placementId) { ATJSSDK_1.default.printLog("AnyThinkInterstitialDemo::onInterstitialAdFailedToShow(" + placementId + ")"); }, //广告被关闭 onInterstitialAdClose: function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("AnyThinkInterstitialDemo::onInterstitialAdClose(" + placementId + ", " + callbackInfo + ")"); //因为跨脚本,所以使用全局注册函数调用,后来发现切换APP,导致ad close事件失效 that.handleCustomEventForInter(); }, //广告被点击 onInterstitialAdClick: function (placementId, callbackInfo) { ATJSSDK_1.default.printLog("AnyThinkInterstitialDemo::onInterstitialAdClick(" + placementId + ", " + callbackInfo + ")"); } }; ATInterstitialJSSDK_1.default.setAdListener(interstitialListener); //插屏广告 }; /** * AD播放完毕的事件处理,插屏处理 */ hallScene.prototype.handleCustomEventForInter = function () { var that = this; console.log('zh:00收到发送的事件handleCustomEventForInter'); var mark = cc.sys.localStorage.getItem("adMarkForClose"); console.log('zh:handleCustomEventForInter mark =' + mark); switch (mark) { case 'callBack_gotoNextLevel': // console.log('zh:点击了点击了超市'); // 调用A页面的方法 // GlobalManager.instance.callMethod('startGameForFailAD', 'value1', 'value2'); GlobalManager_1.default.instance.callMethod('callBack_gotoNextLevel'); break; case 'xxxxxx2222': //开始游戏 //发送事件。。。。todo: 重新开始游戏 //this.node.emit('env_playAdEnd', 'Hello,你好'); // 调用A页面的方法 // GlobalManager.instance.callMethod('startGameForFailAD', 'value1', 'value2'); // GlobalManager.instance.callMethod('startGameForFailAD'); break; default: console.log('zh:未知的inster类型AD' + mark); } }; var hallScene_1; __decorate([ property(cc.Button) ], hallScene.prototype, "startGameBtn", void 0); __decorate([ property(cc.Button) ], hallScene.prototype, "setNormalBtn", void 0); __decorate([ property(cc.Button) ], hallScene.prototype, "missionBtn", void 0); __decorate([ property(cc.Button) ], hallScene.prototype, "btnLeft", void 0); __decorate([ property(cc.Button) ], hallScene.prototype, "btnRight", void 0); __decorate([ property(cc.PageView) ], hallScene.prototype, "pageView", void 0); __decorate([ property(cc.Label) ], hallScene.prototype, "labelTili", void 0); __decorate([ property(cc.Label) ], hallScene.prototype, "physicalTime", void 0); __decorate([ property(cc.Label) ], hallScene.prototype, "labelCoin", void 0); __decorate([ property(cc.Label) ], hallScene.prototype, "labelDiamond", void 0); hallScene = hallScene_1 = __decorate([ ccclass ], hallScene); return hallScene; }(BaseView_1.BaseView)); exports.default = hallScene; cc._RF.pop();