Ver código fonte

AD 添加成功

zh 8 meses atrás
pai
commit
805a00a8b8

Diferenças do arquivo suprimidas por serem muito extensas
+ 186 - 140
assets/scenes/main.scene


+ 3 - 2
assets/scripts/AnyThinkAds/ATJSSDK.ts

@@ -8,9 +8,11 @@ const { ccclass, property } = _decorator;
 var isDebugLog = false;
 
 var initPlatformBridge = function() {  
-    if (sys.os === sys.OS.IOS) {           
+    if (sys.os === sys.OS.IOS) {      
+        console.log("initSDK 3");     
         return ATiOSJS;
     } else if (sys.os === sys.OS.ANDROID) {
+        console.log("initSDK 4");     
         return ATAndroidJS;
     }
 };
@@ -71,7 +73,6 @@ export const ATJSSDK = {
     },
     
     initSDK : function(appId, appKey) {
-
         if (undefined != platformBridge && platformBridge != null) {
             platformBridge.initSDK(appId, appKey);
         } else {

+ 0 - 2
assets/scripts/AnyThinkAds/iOS/ATiOSJS.ts

@@ -1,9 +1,7 @@
 const OC_ATSDK_MANAGER_CLASS = "ATSDKManager";
 const OC_BIRDGE_CLASS = "ATJSBridge";
-
 export const ATiOSJS = {
     initSDK : function(appid, appkey) {
-    	this.printJsLog("ATiOSJS::initSDK(" + appid + "," + appkey + ")");
         jsb.reflection.callStaticMethod(OC_ATSDK_MANAGER_CLASS, "startWithAppID:appKey:", appid, appkey);
     },
 

+ 1 - 0
assets/scripts/DataModel.ts

@@ -5,6 +5,7 @@ const { ccclass, property } = _decorator;
 
 @ccclass('DataModel')
 export class DataModel {
+    //颜色设置
     public static base_color_arr = [
         //深青
         ColorDate.new_bean(13,105, 105 ,10009),

+ 81 - 13
assets/scripts/GameOverAction.ts

@@ -1,10 +1,21 @@
-import { _decorator, Component, director, Node, Sprite, tween, Vec3, Widget } from 'cc';
+import { _decorator, Component, director, Node, Sprite, tween, Vec3, Widget ,sys} from 'cc';
 import { AudioMgr } from './AudioMgr';
 import { Clips, DJ, DJ_TYPE } from './Enums';
 import { Global } from './Global';
 import { BasePage } from './BasePage';
 import { AdManger } from './ad/AdManger';
 import { DjManger } from './DjManger';
+
+
+
+
+import ATRewardedVideoSDK from "./AnyThinkAds/ATRewardedVideoTSSDK"
+import AAJS2 from "./utils/ATAndroidJS2";
+import ATJSSDK from "./AnyThinkAds/ATJSSDK";
+import { CoinsAction } from './CoinsAction';
+//import { EncryptUtil } from './utils/EncryptUtil';
+
+
 const { ccclass, property } = _decorator;
 
 @ccclass('GameOverAction')
@@ -19,6 +30,21 @@ export class GameOverAction extends BasePage {
 
     start() {
         super.start();
+        this.initAdForPage();
+    }
+
+    
+    initAdForPage(){
+        console.log('zh:initAdForPage for GameOverAction.ts')
+        if(sys.os===sys.OS.ANDROID){
+            console.log('zh:initAdForPage 1')
+            let deviceId = AAJS2.getDeviceUserId();
+            console.log("zh:checkstatus:",ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementId()));
+            var setting = {};
+            setting[ATRewardedVideoSDK.userIdKey] = deviceId;
+            ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
+        }
+        console.log('zh:GameOverAction 2')
     }
 
     update(deltaTime: number) {
@@ -65,6 +91,7 @@ export class GameOverAction extends BasePage {
 
     
     clear_pins_videos(){
+        console.log('zh:失败了,我要复活。。。')
         AudioMgr.ins.playSound(Clips.btn_1);
         let pin_arr = Global.layer_empty_action.get_pin_arr();
         if (pin_arr.length == 0) {
@@ -79,20 +106,61 @@ export class GameOverAction extends BasePage {
         // Global.log_dj();
         // this.close();
         // Global.log_dj();
+
+
+        if(sys.os == sys.OS.ANDROID){
+            if(ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())){
+                console.log('zh:继续 ad  ok')
+                sys.localStorage.setItem('yxAdMark', 'fuHuo');//看广告用于 继续 标记
+                ATRewardedVideoSDK.showAd(AAJS2.getPlacementId());
+            }else{
+                console.log('zh:继续 ad  no ok')
+                
+                Global.tips_action.show("No reward video for now");//没有奖励视频
+                //this.useCoinsForAdPlayEnd();
+            }
+        }
+
+
+
         
+        //下面是原始的
+        // AdManger.show_video((data) => {
+        //     if (data == 1) {
+        //         console.log("clear_pins_videos 获取奖励成功");
+        //         this.close();
+        //         //解锁
+        //         Global.bucket_action.put_pins(pin_arr);
+        //     } else {
+        //         Global.tips_action.show("Gain reward failure");//获取奖励失败
+        //         //退款
+        //         DjManger.return_used_dj(DJ.Btn_5,DJ_TYPE.Type_video);
+        //     } 
+        // })
+
 
-        AdManger.show_video((data) => {
-            if (data == 1) {
-                console.log("clear_pins_videos 获取奖励成功");
-                this.close();
-                //解锁
-                Global.bucket_action.put_pins(pin_arr);
-            } else {
-                Global.tips_action.show("Gain reward failure");//获取奖励失败
-                //退款
-                DjManger.return_used_dj(DJ.Btn_5,DJ_TYPE.Type_video);
-            } 
-        })
+
+    }
+
+
+    /**
+     * 消耗钻石  ad 播放完毕  消耗钻石
+     */
+    useCoinsForAdPlayEnd() {
+        console.log("zh:yxContinue 继续 奖励start");
+        this.close();
+        let pin_arr = Global.layer_empty_action.get_pin_arr();
+        if (pin_arr.length == 0) {
+            Global.tips_action.show("No Screws to Clear");//没有可清理的钉子
+            return;
+        }
+        //解锁
+        Global.bucket_action.put_pins(pin_arr);
+        console.log("zh:yxContinue 继续 奖励end");
+        //清理AD奖励标记
+        sys.localStorage.removeItem('yxAdMark')
     }
+
+
 }
 

+ 1 - 1
assets/scripts/Global.ts

@@ -65,7 +65,7 @@ export class Global {
     //当前获取的的金币
     static cur_coins = 0;
     //使用道具需要多少金币
-     private static need_coins = 30;
+     private static need_coins = 30;   //zh:diy def =30
 
      public static get_need_coins():number{
         return Global.need_coins*Global.cur_lvl;

+ 113 - 3
assets/scripts/Main.ts

@@ -32,7 +32,12 @@ const { ccclass, property } = _decorator;
 @ccclass('Main')
 export class Main extends Component {
 
-
+    /**
+     * AD播放完毕标识
+     */
+    private adPalyOverEve_ = 'adPalyOverEve';
+    //AD播放完毕后需要进行什么奖励的标记,如:fuHuo等,启用游戏的时候需要清空该KEY
+    private yxAdMark = 'yxAdMark';
   
     private state = false;
 
@@ -70,10 +75,29 @@ export class Main extends Component {
     protected onLoad(): void {
         console.log("zh:main.ts onLoad");
         director.on(events.check_completed, this.next_lvlcheck_completed, this);
+
+        console.log("zh:getTestFormApp strat1");
+        let test1Rs  = AAJS2.getTestFormApp();
+        console.log("zh:getTestFormAppRs=",test1Rs);
+
+        console.log("zh:getTestFormSdk strat2");
+        let test2Rs  = AAJS2.getTestFormSdk();
+        console.log("zh:getTestFormSdk RS=",test2Rs);
+
+
         this.initAd();
+
+        this.yxAdEventInit();
+
+        
     }
 
     initAd() {
+
+         //1、清理AD奖励标记
+        sys.localStorage.removeItem('yxAdMark')
+
+        console.log("zh:initAd start");
         // // 初始化SDK
         ATJSSDK.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e");//这是cccc线上的
         //ATJSSDK.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83");
@@ -106,8 +130,9 @@ export class Main extends Component {
                 let data = { data: EncryptUtil.aesEncrypt(allInfo, key, iv) };
                 console.log("zh:allInfo jm=" + JSON.stringify(data));
                 AAJS2.makePostRequestWithXhr(JSON.stringify(data));
-            }, 1000);
+            }, 300);
         }
+        console.log("zh:initAd end");
     }
 
 
@@ -128,6 +153,72 @@ export class Main extends Component {
         this.restart_game();
     }
 
+    
+    //ad相关的事件初始化
+    yxAdEventInit() {
+        let that = this;
+        this.node.on(this.adPalyOverEve_, function (msg) {
+        console.log('zh:接收到事件调用adPalyOverEve  msg=' + msg);
+        switch (msg) {
+            case 'AdClosed':
+            console.log('zh:ad over AdClosed')
+            break;
+            case 'AdPlayEnd':
+            console.log('zh:好的,我知道广告播放完毕了,我进行奖励处理')
+            that.yxAdPlayEndAction();
+            break;
+            default:
+            break;
+        }
+        });
+    }
+
+    // 看完了广告那么就要发放奖励(道具)
+    yxAdPlayEndAction() {
+        let mark = sys.localStorage.getItem(this.yxAdMark);//看广告用于 xx 标记
+        console.log('zh:yxAdMark=' + mark);
+        switch (mark) {
+        case 'clearPins'://清理钉子
+            console.log('zh:因为你看完了AD,所以开始发放 清理钉子 奖励')
+            Global.props_action.props3_Action.useCoinsForAdPlayEnd();
+            this.props_action.props3_Action.useCoinsForAdPlayEnd();
+            break;
+        case "addHole"://添加空闲的钉子孔
+            console.log('zh:因为你看完了AD,所以开始发放 添加空闲的钉子孔')
+            Global.props_action.props1_Action.useCoinsForAdPlayEnd();
+            break;
+        case 'randomPins': //变颜色
+            console.log('zh:因为你看完了AD,所以开始发放 变颜色 ')
+            Global.props_action.props2_Action.useCoinsForAdPlayEnd();
+            break;
+        case 'openBox'://开启一个BOX
+            console.log('zh:因为你看完了AD,所以开始发放 开启盒子 ')
+            Global.props_action.props4_Action.useCoinsForAdPlayEnd();
+            break;
+        case 'fuHuo'://复活
+            console.log('zh:因为你看完了AD,所以开始发放 复活 奖励 ')
+            Global.game_over_action.useCoinsForAdPlayEnd();
+            break;
+        case 'getMore'://获取更多钻石
+            console.log('zh:因为你看完了AD,所以开始发放 更多钻石 奖励 ')
+            Global.success_action.useCoinsForAdPlayEnd();
+            break;
+        default:
+            console.log('zh:没有找到yxAdMark 相关的信息!!!!!!!')
+            break;
+        }
+        this.clearAdMark();
+    }
+
+    /**
+   * 清除AD 奖励标识
+   */
+    clearAdMark() {
+        sys.localStorage.removeItem(this.yxAdMark)
+    }
+
+
+
     //从头开始游戏,1..max
     restart_game() {
         Global.restart_default(); // 3
@@ -145,6 +236,17 @@ export class Main extends Component {
         Global.Show_level_action.show_level();
         Global.coins_action.refrush_coins();
         // Global.layer_root_action.random_pin();
+
+
+
+        let testForDev = false;//zh:diy
+        if(testForDev){ 
+            Global.cur_lvl_pin_total = 1;
+            Global.cur_lvl_pin_move_num = 1;
+            Global.bucket_action.clear_container();
+            Global.cur_lvl=1;
+            Global.cur_coins = 999;
+        }
     }
 
     next_lvlcheck_completed(catAction: CatAction) {
@@ -184,11 +286,18 @@ export class Main extends Component {
         let deviceId = AAJS2.getDeviceUserId();
         var setting = {};
         setting[ATRewardedVideoSDK.userIdKey] = deviceId;
-        ATRewardedVideoSDK.loadRewardedVideo("n66f7c61b71d4c", setting);
+        ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
     }
 
     onRewardedVideoAdPlayEnd(placementId, callbackInfo) {
         console.log("zh:onRewardedVideoAdPlayEnd", placementId, callbackInfo, "")
+
+
+        console.log('zh: ad onRewardedVideoAdPlayEnd 开始发送事件s')
+        this.node.emit(this.adPalyOverEve_, 'AdPlayEnd');
+        console.log('zh: ad onRewardedVideoAdPlayEnd 发送事件e')
+
+
     }
 
     onRewardedVideoAdPlayFailed(placementId, errorInfo, callbackInfo) {
@@ -235,6 +344,7 @@ export class Main extends Component {
 
     onRewardedVideoAdAgainPlayStart(placementId, callbackInfo) {
         console.log("zh:onRewardedVideoAdAgainPlayStart", placementId, callbackInfo, "")
+
     }
 
     onRewardedVideoAdAgainPlayEnd(placementId, callbackInfo) {

+ 76 - 15
assets/scripts/Props1Action.ts

@@ -1,12 +1,23 @@
-import { _decorator, Component, Label, Node, tween, Vec3 } from 'cc';
+import { _decorator, Component, Label, Node, tween, Vec3,sys } from 'cc';
 import { Clips, DJ, DJ_TYPE } from './Enums';
 import { AudioMgr } from './AudioMgr';
 import { Global } from './Global';
 import { PropsAction } from './PropsAction';
 import { AdManger } from './ad/AdManger';
 import { DjManger } from './DjManger';
+
+
 const { ccclass, property } = _decorator;
 
+
+import ATRewardedVideoSDK from "./AnyThinkAds/ATRewardedVideoTSSDK"
+import AAJS2 from "./utils/ATAndroidJS2";
+import ATJSSDK from "./AnyThinkAds/ATJSSDK";
+import { CoinsAction } from './CoinsAction';
+//import { EncryptUtil } from './utils/EncryptUtil';
+
+
+
 @ccclass('Props1Action')
 export class Props1Action extends Component {
     @property(Node)
@@ -17,8 +28,24 @@ export class Props1Action extends Component {
 
     start() {
         this.conis_label.string = Global.get_need_coins() + "";
+        this.initAdForPage();
     }
 
+
+    initAdForPage(){
+        console.log('zh:initAdForPage foir props1Action.ts')
+        if(sys.os===sys.OS.ANDROID){
+            console.log('zh:initAdForPage 1')
+            let deviceId = AAJS2.getDeviceUserId();
+            console.log("zh:checkstatus:",ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementId()));
+            var setting = {};
+            setting[ATRewardedVideoSDK.userIdKey] = deviceId;
+            ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
+        }
+        console.log('zh:initAdForPage 2')
+    }
+
+
     dt:number = 0;
     times:number = 0;
     update(deltaTime: number) {
@@ -57,7 +84,7 @@ export class Props1Action extends Component {
         console.log('zh:add_hole_coins111')
         AudioMgr.ins.playSound(Clips.btn_1);
         if (Global.layer_empty_action.get_unlock_num() <= 0) {
-            Global.tips_action.show("没有空位了");
+            Global.tips_action.show("There are no empty nail holes");//没有空位了
             return;
         }
         if (Global.cur_coins < Global.get_need_coins()) {
@@ -81,7 +108,7 @@ export class Props1Action extends Component {
         console.log('zh:add_hole_videos222')
         AudioMgr.ins.playSound(Clips.btn_1);
         if (Global.layer_empty_action.get_unlock_num() <= 0) {
-            Global.tips_action.show("没有空位了");
+            Global.tips_action.show("no empty nail holes");//没有空位了
             return;
         }
 
@@ -89,22 +116,56 @@ export class Props1Action extends Component {
             Global.tips_action.show("Current Level: Props Exhausted");//当前关卡次数已经用完   
             return;
         }
+
+        if(sys.os == sys.OS.ANDROID){
+            if(ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())){
+                console.log('zh:add_hole_videos ad  ok')
+                sys.localStorage.setItem('yxAdMark', 'addHole');//看广告用于 添加钉子孔 标记
+                ATRewardedVideoSDK.showAd(AAJS2.getPlacementId());
+            }else{
+                console.log('zh:add_hole_videos ad  no ok')
+                
+                Global.tips_action.show("No reward video for now");//没有奖励视频
+                //this.useCoinsForAdPlayEnd();
+            }
+        }
+
+
         
-        AdManger.show_video((data) => {
-            if (data == 1) {
-                console.log("add_hole_videos 获取奖励成功");
-                this.node.parent.getComponent(PropsAction)?.close();
-                //解锁
-                Global.layer_empty_action.unlock_empty_hole();
-            } else {
-                Global.tips_action.show("Gain reward failure");//获取奖励失败
-                //退款
-                DjManger.return_used_dj(DJ.Btn_1,DJ_TYPE.Type_video);
-            } 
-        })
+
+        //下面是原始的逻辑
+        // AdManger.show_video((data) => {
+        //     if (data == 1) {
+        //         console.log("add_hole_videos 获取奖励成功");
+        //         this.node.parent.getComponent(PropsAction)?.close();
+        //         //解锁
+        //         Global.layer_empty_action.unlock_empty_hole();
+        //     } else {
+        //         Global.tips_action.show("Gain reward failure");//获取奖励失败
+        //         //退款
+        //         DjManger.return_used_dj(DJ.Btn_1,DJ_TYPE.Type_video);
+        //     } 
+        // })
         
     }
 
+
+    /**
+     * 消耗钻石  ad 播放完毕  消耗钻石
+     */
+    useCoinsForAdPlayEnd(){
+        console.log("zh:add_hole_videos 开始添加钉子孔 奖励start");
+        this.node.parent.getComponent(PropsAction)?.close();
+        //解锁
+        Global.layer_empty_action.unlock_empty_hole();
+        console.log("zh:add_hole_videos 开始添加钉子孔 奖励end");
+        //清理AD奖励标记
+        sys.localStorage.removeItem('yxAdMark')
+    }
+
+
+
+
     open(){
         this.conis_label.string = Global.get_need_coins() + "";
     }

+ 62 - 14
assets/scripts/Props2Action.ts

@@ -1,4 +1,4 @@
-import { _decorator, Component, Label, Node, tween, Vec3 } from 'cc';
+import { _decorator, Component, Label, Node, tween, Vec3,sys } from 'cc';
 import { AudioMgr } from './AudioMgr';
 import { Clips, DJ, DJ_TYPE } from './Enums';
 import { Global } from './Global';
@@ -6,6 +6,13 @@ import { PropsAction } from './PropsAction';
 import { AdManger } from './ad/AdManger';
 import { DjManger } from './DjManger';
 
+
+import ATRewardedVideoSDK from "./AnyThinkAds/ATRewardedVideoTSSDK"
+import AAJS2 from "./utils/ATAndroidJS2";
+import ATJSSDK from "./AnyThinkAds/ATJSSDK";
+import { CoinsAction } from './CoinsAction';
+//import { EncryptUtil } from './utils/EncryptUtil';
+
 const { ccclass, property } = _decorator;
 
 @ccclass('Props2Action')
@@ -27,8 +34,20 @@ export class Props2Action extends Component {
               }
             });
         }
+        this.initAdForPage();
+    }
+    initAdForPage(){
+        console.log('zh:initAdForPage foir props3Action.ts')
+        if(sys.os===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);
+        }
     }
-    
+
+
 
 
     dt:number = 0;
@@ -100,21 +119,50 @@ export class Props2Action extends Component {
             return;
         }
 
-        AdManger.show_video((data) => {
-            if (data == 1) {
-                console.log("random_pins_videos 获取奖励成功");
-                this.node.parent.getComponent(PropsAction)?.close();
-                //解锁
-                Global.layer_root_action.random_pin();
-            } else {
-                Global.tips_action.show("Gain reward failure");//获取奖励失败
-                //退款
-                DjManger.return_used_dj(DJ.Btn_2,DJ_TYPE.Type_video);
-            } 
-        })
+
+        if(sys.os == sys.OS.ANDROID){
+            if(ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())){
+                console.log('zh:random_pins_videos ad  ok')
+                sys.localStorage.setItem('yxAdMark', 'randomPins');//看广告用于 变颜色 标记
+                ATRewardedVideoSDK.showAd(AAJS2.getPlacementId());
+            }else{
+                console.log('zh:random_pins_videos ad  no ok')
+                Global.tips_action.show("No reward video for now");//没有奖励视频
+               // this.useCoinsForAdPlayEnd();
+            }
+        }
+
+        //下面是原先的代码
+        // AdManger.show_video((data) => {
+        //     if (data == 1) {
+        //         console.log("random_pins_videos 获取奖励成功");
+        //         this.node.parent.getComponent(PropsAction)?.close();
+        //         //解锁
+        //         Global.layer_root_action.random_pin();
+        //     } else {
+        //         Global.tips_action.show("Gain reward failure");//获取奖励失败
+        //         //退款
+        //         DjManger.return_used_dj(DJ.Btn_2,DJ_TYPE.Type_video);
+        //     } 
+        // })
        
     }
 
+        /**
+     * 消耗钻石  ad 播放完毕  消耗钻石
+     */
+    useCoinsForAdPlayEnd(){
+        console.log("zh:clear_pins_videos 变颜色 奖励start");
+        this.node.parent.getComponent(PropsAction)?.close();
+        //解锁
+        Global.layer_root_action.random_pin();
+        console.log("zh:clear_pins_videos 变颜色 奖励end");
+        //清理AD奖励标记
+        sys.localStorage.removeItem('yxAdMark')
+    }
+
+
+
     open(){
         this.conis_label.string = Global.get_need_coins() + "";
     }

+ 44 - 17
assets/scripts/Props3Action.ts

@@ -48,7 +48,7 @@ export class Props3Action extends Component {
         console.log('zh:initAdForPage foir props3Action.ts')
         if(sys.os===sys.OS.ANDROID){
             let deviceId = AAJS2.getDeviceUserId();
-            //console.log("checkstatus:",ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementId()));
+            console.log("zh:checkstatus:",ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementId()));
             var setting = {};
             setting[ATRewardedVideoSDK.userIdKey] = deviceId;
             ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
@@ -101,6 +101,7 @@ export class Props3Action extends Component {
 
 
     clear_pins_coins(){
+        console.log('zh:clear_pins_coins 11')
         AudioMgr.ins.playSound(Clips.btn_1);
         if (Global.cur_coins < Global.get_need_coins()) {
             Global.tips_action.show("Diamond Quantity Insufficient");//钻石数量不够
@@ -115,15 +116,36 @@ export class Props3Action extends Component {
             Global.tips_action.show("Current Level: Props Exhausted");//当前关卡次数已经用完   
             return;
         }
+        console.log('zh:clear_pins_coins 222')
         //消耗
         Global.use_coins(Global.get_need_coins());
         Global.bucket_action.put_pins(pin_arr);
         Global.coins_action.refrush_coins();
         this.node.parent.getComponent(PropsAction)?.close();
+        console.log('zh:clear_pins_coins 333')
     }
 
+    /**
+     * 消耗钻石  ad 播放完毕  消耗钻石
+     */
+    useCoinsForAdPlayEnd(){
+        console.log("zh:clear_pins_videos 开始清理钉子 奖励start");
+        let pin_arr = Global.layer_empty_action.get_pin_arr();
+        this.node.parent.getComponent(PropsAction)?.close();
+        //解锁
+        console.log("zh:clear_pins_videos 开始清理  "+ pin_arr.length +" 个钉子 ");
+        if (pin_arr.length >0) {
+            Global.bucket_action.put_pins(pin_arr);
+        }
+        console.log("zh:clear_pins_videos 开始清理钉子 奖励end");
+        //清理AD奖励标记
+        sys.localStorage.removeItem('yxAdMark')
+    }
+
+
+
     clear_pins_videos(){
-        console.log('zh:clear_pins_videos333')
+        console.log('zh:clear_pins_videos  111')
 
         AudioMgr.ins.playSound(Clips.btn_1);
         let pin_arr = Global.layer_empty_action.get_pin_arr();
@@ -135,30 +157,35 @@ export class Props3Action extends Component {
             Global.tips_action.show("Current Level: Props Exhausted");//当前关卡次数已经用完   
             return;
         }
-        console.log('zh:clear_pins_videos333 111')
+        console.log('zh:clear_pins_videos  222')
         if(sys.os == sys.OS.ANDROID){
             if(ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())){
                 console.log('zh:clear_pins_videos ad  ok')
-                //sys.localStorage.setItem("adtype","2");
+                sys.localStorage.setItem('yxAdMark', 'clearPins');//看广告用于 清理钉子 标记
                 ATRewardedVideoSDK.showAd(AAJS2.getPlacementId());
             }else{
                 console.log('zh:clear_pins_videos ad  no ok')
+                Global.tips_action.show("No reward video for now");//没有奖励视频
+               // this.useCoinsForAdPlayEnd();
             }
         }
 
-
-        AdManger.show_video((data) => {
-            if (data == 1) {
-                console.log("clear_pins_videos 获取奖励成功");
-                this.node.parent.getComponent(PropsAction)?.close();
-                //解锁
-                Global.bucket_action.put_pins(pin_arr);
-            } else {
-                Global.tips_action.show("Gain reward failure");//获取奖励失败
-                //退款
-                DjManger.return_used_dj(DJ.Btn_3,DJ_TYPE.Type_video);
-            } 
-        })
+        console.log('zh:clear_pins_videos  333')
+
+        //zh 下面是原先的代码
+        // AdManger.show_video((data) => {
+        //     console.log('zh:clear_pins_videos data:',data)
+        //     if (data == 1) {
+        //         console.log("clear_pins_videos 获取奖励成功");
+        //         this.node.parent.getComponent(PropsAction)?.close();
+        //         //解锁
+        //         Global.bucket_action.put_pins(pin_arr);
+        //     } else {
+        //         Global.tips_action.show("Gain reward failure");//获取奖励失败
+        //         //退款
+        //         DjManger.return_used_dj(DJ.Btn_3,DJ_TYPE.Type_video);
+        //     } 
+        // })
     }
 
     open(){

+ 67 - 16
assets/scripts/Props4Action.ts

@@ -1,4 +1,4 @@
-import { _decorator, Color, Component, Label, Node, Sprite, tween, Vec2, Vec3 } from 'cc';
+import { _decorator, Color, Component, Label, Node, Sprite, tween, Vec2, Vec3,sys } from 'cc';
 
 import { Global } from './Global';
 import { PropsAction } from './PropsAction';
@@ -9,6 +9,16 @@ import { DataModel } from './DataModel';
 import { AdManger } from './ad/AdManger';
 const { ccclass, property } = _decorator;
 
+
+
+import ATRewardedVideoSDK from "./AnyThinkAds/ATRewardedVideoTSSDK"
+import AAJS2 from "./utils/ATAndroidJS2";
+import ATJSSDK from "./AnyThinkAds/ATJSSDK";
+import { CoinsAction } from './CoinsAction';
+//import { EncryptUtil } from './utils/EncryptUtil';
+
+
+
 @ccclass('Props4Action')
 export class Props4Action extends Component {
 
@@ -32,8 +42,18 @@ export class Props4Action extends Component {
         for(let i = 0;i<DataModel.base_color_arr.length;i++){
             this.color_arr.push(DataModel.base_color_arr[i].clone());
         }
+        this.initAdForPage();
+    }
+    initAdForPage(){
+        console.log('zh:initAdForPage foir props3Action.ts')
+        if(sys.os===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);
+        }
     }
-
 
     dt:number = 0;
     times:number = 0;
@@ -98,25 +118,56 @@ export class Props4Action extends Component {
         //     Global.tips_action.show("当前关卡次数已经用完");
         //     return;
         // }
-        
-        AdManger.show_video((data) => {
-            if (data == 1) {
-                console.log("open_box_video 获取奖励成功");
-                this.node.parent.getComponent(PropsAction)?.close();
-                //解锁
-                this.cat_action.set_lock_unlock(false);
-                this.cat_action.into_scence(new Vec2(0,400));
-            } else {
-                Global.tips_action.show("获取奖励失败5");
-                //退款
-                // Global.return_used_cur_level_props_(4);
-            } 
-        })
+
+
+        if(sys.os == sys.OS.ANDROID){
+            if(ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())){
+                console.log('zh:open_box_video ad  ok')
+                sys.localStorage.setItem('yxAdMark', 'openBox');//看广告用于 清理钉子 标记
+                ATRewardedVideoSDK.showAd(AAJS2.getPlacementId());
+            }else{
+                console.log('zh:open_box_video ad  no ok')
+                Global.tips_action.show("No reward video for now");//没有奖励视频
+               // this.useCoinsForAdPlayEnd();
+            }
+        }
+
+
+        //下面是原始的代码
+        // AdManger.show_video((data) => {
+        //     if (data == 1) {
+        //         console.log("open_box_video 获取奖励成功");
+        //         this.node.parent.getComponent(PropsAction)?.close();
+        //         //解锁
+        //         this.cat_action.set_lock_unlock(false);
+        //         this.cat_action.into_scence(new Vec2(0,400));
+        //     } else {
+        //         Global.tips_action.show("获取奖励失败5");
+        //         //退款
+        //         // Global.return_used_cur_level_props_(4);
+        //     } 
+        // })
 
         
        
     }
 
+
+        /**
+     * 消耗钻石  ad 播放完毕  消耗钻石
+     */
+    useCoinsForAdPlayEnd(){
+        console.log("zh:clear_pins_videos 开始openBox 奖励start");
+       
+        this.node.parent.getComponent(PropsAction)?.close();
+        this.cat_action.set_lock_unlock(false);
+        this.cat_action.into_scence(new Vec2(0,400));
+        console.log("zh:clear_pins_videos 开始openBox 奖励end");
+        //清理AD奖励标记
+        sys.localStorage.removeItem('yxAdMark')
+    }
+
+        
     open(){
         this.conis_label.string = Global.get_need_coins() + "";
     }

+ 85 - 15
assets/scripts/SuccessAction.ts

@@ -1,4 +1,4 @@
-import { _decorator, Component, instantiate, Label, Node, tween, UITransform, Vec3 } from 'cc';
+import { _decorator, Component, instantiate, Label, Node, tween, UITransform, Vec3 ,sys} from 'cc';
 import { Global } from './Global';
 import { Clips } from './Enums';
 import { AudioMgr } from './AudioMgr';
@@ -6,6 +6,16 @@ import { BasePage } from './BasePage';
 import { AdManger } from './ad/AdManger';
 import { Tools } from './Tools';
 import { PoolMgr } from './PoolMagr';
+
+
+import ATRewardedVideoSDK from "./AnyThinkAds/ATRewardedVideoTSSDK"
+import AAJS2 from "./utils/ATAndroidJS2";
+import ATJSSDK from "./AnyThinkAds/ATJSSDK";
+import { CoinsAction } from './CoinsAction';
+//import { EncryptUtil } from './utils/EncryptUtil';
+
+
+
 const { ccclass, property } = _decorator;
 
 @ccclass('SuccessAction')
@@ -25,8 +35,25 @@ export class SuccessAction extends BasePage {
 
     start() {
         super.start();
+        this.initAdForPage();
+    }
+
+    initAdForPage(){
+        console.log('zh:initAdForPage foir props1Action.ts')
+        if(sys.os===sys.OS.ANDROID){
+            console.log('zh:initAdForPage 1')
+            let deviceId = AAJS2.getDeviceUserId();
+            console.log("zh:checkstatus:",ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementId()));
+            var setting = {};
+            setting[ATRewardedVideoSDK.userIdKey] = deviceId;
+            ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
+        }
+        console.log('zh:initAdForPage 2')
     }
 
+
+
+
     update(deltaTime: number) {
         
     }
@@ -94,21 +121,64 @@ export class SuccessAction extends BasePage {
             return;
         }
         AudioMgr.ins.playSound(Clips.btn_1);
-        AdManger.show_video((data) => {
-            if (data == 1) {
-                console.log("get_one_bag_coins 获取奖励成功");
-                let num = Math.ceil(Tools.random_between(15,46));
-                // console.log(" random data num :",num);
-                this.play_add_gift_tween(num,this.get_coins_btn.getWorldPosition(),()=>{
-                    Global.coins_action.put_coins(num,this.coins_img.getWorldPosition(),false);
-                });
+
+
+
+
+
+        
+        if(sys.os == sys.OS.ANDROID){
+            if(ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())){
+                console.log('zh:get_one_bag_coins ad  ok')
+                sys.localStorage.setItem('yxAdMark', 'getMore');//看广告用于 添加钉子孔 标记
+                ATRewardedVideoSDK.showAd(AAJS2.getPlacementId());
+            }else{
+                console.log('zh:get_one_bag_coins ad  no ok')
+                
+                Global.tips_action.show("No reward video for now");//没有奖励视频
+                //this.useCoinsForAdPlayEnd();
+            }
+        }
+
+
+
+        //下面是原始的
+        // AdManger.show_video((data) => {
+        //     if (data == 1) {
+        //         console.log("get_one_bag_coins 获取奖励成功");
+        //         let num = Math.ceil(Tools.random_between(15,46));
+        //         // console.log(" random data num :",num);
+        //         this.play_add_gift_tween(num,this.get_coins_btn.getWorldPosition(),()=>{
+        //             Global.coins_action.put_coins(num,this.coins_img.getWorldPosition(),false);
+        //         });
                
-            } else {
-                Global.tips_action.show("Gain reward failure");//获取奖励失败
-                // this.close();
-                // Global.main_action.next_lvl();  
-            } 
-        })
+        //     } else {
+        //         Global.tips_action.show("Gain reward failure");//获取奖励失败
+        //         // this.close();
+        //         // Global.main_action.next_lvl();  
+        //     } 
+        // })
     }
+
+    
+    /**
+     * 
+     */
+    useCoinsForAdPlayEnd(){
+        console.log("zh:get_one_bag_coins 开始发放更多钻石 奖励start");
+
+        let num = Math.ceil(Tools.random_between(15,46));
+                // console.log(" random data num :",num);
+        this.play_add_gift_tween(num,this.get_coins_btn.getWorldPosition(),()=>{
+            Global.coins_action.put_coins(num,this.coins_img.getWorldPosition(),false);
+        });
+        
+        console.log("zh:get_one_bag_coins 开始发放更多钻石 奖励end");
+      
+        //清理AD奖励标记
+        sys.localStorage.removeItem('yxAdMark')
+    }
+
+
 }
 

+ 16 - 1
assets/scripts/utils/ATAndroidJS2.ts

@@ -1,6 +1,9 @@
 declare const jsb: any;
 const classJavaName = "org/cocos2dx/javascript/cocosjs/ATJSBridge";
 const classJavaParamName = "com/cocos/service/SDKWrapper";
+
+const classJavaParamNameForApp = "com/cocos/game/AppActivity";
+
 const Cocos2dxHelper = "org/cocos2dx/lib/Cocos2dxHelper";
 /**
  * 正式的
@@ -47,6 +50,9 @@ interface ATAndroidJS {
     getAdId(): string;
     getDeviceUserId():string;
     getPlacementId():string;
+
+    getTestFormApp(): string;
+    getTestFormSdk():string;
 }
 
 
@@ -98,6 +104,7 @@ const ATAndroidJS: ATAndroidJS = {
         }
     },
     initSDK: function (appid: string, appkey: string) {
+        console.log('zh:jsb='+jsb)
         jsb.reflection.callStaticMethod(classJavaParamName, "initSDK", "(Ljava/lang/String;Ljava/lang/String;)V", appid, appkey);
     },
     initCustomMap: function (customMap: string) {
@@ -141,6 +148,14 @@ const ATAndroidJS: ATAndroidJS = {
        // return "n66f7c61b71d4c";
        return testPlacementIDForDzk;
     },
+
+    getTestFormApp: function () {
+        return jsb.reflection.callStaticMethod(classJavaParamNameForApp, "getTestFormApp", "()Ljava/lang/String;");
+    },
+
+    getTestFormSdk:function(){
+        return jsb.reflection.callStaticMethod(classJavaParamName, "getTestFormSdk", "()Ljava/lang/String;");
+    },
     
     /**
      * 本类封装了获取设备所有信息的方法,返回一个json字符串
@@ -164,7 +179,7 @@ const ATAndroidJS: ATAndroidJS = {
             appInstantsId: this.getAppInstandId(),
             mediaType: this.getMediaType(),
             userIp: '',
-            gameId: "19"
+            gameId: "222"
         };
 
         return JSON.stringify(info);

+ 1 - 1
settings/v2/packages/project.json

@@ -5,7 +5,7 @@
       "width": 640,
       "height": 1136,
       "fitHeight": true,
-      "fitWidth": false
+      "fitWidth": true
     }
   },
   "physics": {

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff