123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- import { BaseView } from "../../../lightMVC/core/base/BaseView";
- import { App } from "../../Manager/App";
- import { Sex } from "../../Framework/Const/EnumDefine";
- import SuperScrollView from "../SuperScrollview/SuperScrollView";
- import MissionItem from "./MissionItem";
- import AESUtil from "../../AESUtil"
- import ATSDK from "../../AnyThinkAds/ATJSSDK";
- import ATRewardedVideoSDK from "../../AnyThinkAds/ATRewardedVideoJSSDK";
- import AAJS2 from "../../ATAndroidJS2";
- import GlobalManager from '../../GlobalManager';
- import ATInterstitialSDK from "../../AnyThinkAds/ATInterstitialJSSDK";
- import ATBannerSDK from "../../AnyThinkAds/ATBannerJSSDK";
- import { AdType } from '../../ATAndroidJS2';
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class MissionPanel extends BaseView {
- private skinNum: number = 6;
- private currentNum: number = 1;
- private list: any[] = [];
- protected onLoad(): void {
- console.log('zh:MissionPanel.ts onload ');
- //这个地方加了会有问题,导致列表无法加载
- // this.initAdForPageInter();
- // setTimeout(() => {
- // this.showInterAd("callBackFor_ClickBackMain",false, null);
- // }, 100);
- }
-
-
- //add判断插屏 开屏等,需要多次准备
- //add判断插屏 开屏等,需要多次准备
- initAdForPageInter() {
- if (cc.sys.os === cc.sys.OS_ANDROID) {
- console.log('zh:skillBox.ts 开始准备AD .....');
- let deviceId = AAJS2.getDeviceUserId();
- var setting = {};
- setting[ATRewardedVideoSDK.userIdKey] = deviceId;
- //add判断插屏 开屏等
- let pid_inter = AAJS2.getPlacementId2(AdType.Inter);
- console.log("zh: pid_inter checkstatus:", ATInterstitialSDK.checkAdStatus(pid_inter));
- ATInterstitialSDK.loadInterstitial(pid_inter, setting);
- }
- }
- public drawView(): void {
- console.log('zh:drawView');
- for (let i = 0; i < App.DataManager.MissionDataList.length; i++) {
- this.list[i] = i;
- }
- // 返回
- let closeBtn = this.ui.getNode("close");
- closeBtn.on(cc.Node.EventType.TOUCH_END, () => {
- this.closeView();
- }, this);
- this.CreateLevel();
- this.ui.getNode("item").active = false;
- }
- /**
- * 生成皮肤列表
- */
- private CreateLevel(): void {
- console.log('zh:CreateLevel');
- let skinList = this.ui.getNode("List");
- skinList.getComponent(SuperScrollView).setData(this.list, false, null);
- }
- public static path(): string {
- return "hallScene/prefabs/MissionPanel";
- }
-
- /**
- * 显示插屏广告
- *
- * @param adMarkForClose 插屏广告关闭后调用那个方法的具体指示标识
- * @param checkClose 是否需要判断关闭事件,有的不需要,如果AD占用游戏时间则为true
- * @param callback 插屏广告关闭(加载失败\非ANDROID平台)的回调
- */
- private showInterAd(adMarkForClose: string, checkClose: boolean, callback: () => void) {
- if (cc.sys.os === cc.sys.OS_ANDROID) {
- if (checkClose) {
- cc.sys.localStorage.setItem("adMarkForClose", adMarkForClose);//关闭后,调用哪个方法的标识
- }
- //add判断插屏 开屏等
- let pid_inter = AAJS2.getPlacementId2(AdType.Inter);
- let boo = ATInterstitialSDK.hasAdReady(pid_inter);
- if (boo) {
- // 暂停游戏
- cc.director.pause();
- console.log('zh:showInterAd AD OK');
- ATInterstitialSDK.showAd(pid_inter);
- //因为跨脚本,所以使用全局注册函数调用,后来发现切换APP,导致ad close事件失效
- if (!checkClose) {//如果不占用游戏时间
- this.safeCallback(callback);
- }
- } else {
- console.log('zh:showInterAd AD 没有准备好');
- //GlobalManager.getInstance().callMethod('initAdForPageInter');
- //this.initAdForPageInter();
- this.safeCallback(callback);
- }
- } else {
- this.safeCallback(callback);
- }
- }
- // 辅助方法:安全调用回调函数
- private safeCallback(callback?: () => void) {
- if (callback) {
- callback();
- }
- }
- }
|