Browse Source

事件测试OK,复活测试

zh 8 months ago
parent
commit
f0b387ad4b

+ 53 - 33
assets/Scene/scene.fire

@@ -2837,8 +2837,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 50,
-      "height": 91
+      "width": 200,
+      "height": 60
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -2849,7 +2849,7 @@
       "__type__": "TypedArray",
       "ctor": "Float64Array",
       "array": [
-        -108,
+        -196,
         197,
         0,
         0,
@@ -2893,7 +2893,7 @@
       "__uuid__": "28e187c0-7af4-4ca2-baaf-a0443edd890d"
     },
     "_type": 0,
-    "_sizeMode": 1,
+    "_sizeMode": 0,
     "_fillType": 0,
     "_fillCenter": {
       "__type__": "cc.Vec2",
@@ -2931,7 +2931,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 25.9,
+      "width": 180,
       "height": 56.4
     },
     "_anchorPoint": {
@@ -2943,8 +2943,8 @@
       "__type__": "TypedArray",
       "ctor": "Float64Array",
       "array": [
-        -106,
-        198,
+        -200,
+        200,
         0,
         0,
         0,
@@ -2983,9 +2983,9 @@
     ],
     "_srcBlendFactor": 770,
     "_dstBlendFactor": 771,
-    "_string": "Hero",
-    "_N$string": "Hero",
-    "_fontSize": 30,
+    "_string": "name",
+    "_N$string": "name",
+    "_fontSize": 28,
     "_lineHeight": 30,
     "_enableWrapText": true,
     "_N$file": null,
@@ -3009,7 +3009,7 @@
       "__id__": 51
     },
     "_children": [],
-    "_active": false,
+    "_active": true,
     "_components": [
       {
         "__id__": 61
@@ -3026,7 +3026,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 40,
+      "width": 60,
       "height": 40
     },
     "_anchorPoint": {
@@ -3038,8 +3038,8 @@
       "__type__": "TypedArray",
       "ctor": "Float64Array",
       "array": [
-        -94,
-        206,
+        -146,
+        224,
         0,
         0,
         0,
@@ -3071,7 +3071,11 @@
       "__id__": 60
     },
     "_enabled": true,
-    "_materials": [],
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
     "_srcBlendFactor": 770,
     "_dstBlendFactor": 771,
     "_string": "lv1",
@@ -3082,14 +3086,14 @@
     "_N$file": null,
     "_isSystemFontUsed": true,
     "_spacingX": 0,
-    "_batchAsBitmap": true,
+    "_batchAsBitmap": false,
     "_styleFlags": 0,
     "_underlineHeight": 0,
     "_N$horizontalAlign": 1,
     "_N$verticalAlign": 1,
     "_N$fontFamily": "Arial",
     "_N$overflow": 2,
-    "_N$cacheMode": 0,
+    "_N$cacheMode": 1,
     "_id": "62fiicvKZHzpQpAp2ff9tM"
   },
   {
@@ -10392,7 +10396,11 @@
       "__id__": 215
     },
     "_enabled": true,
-    "_materials": [],
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
     "_srcBlendFactor": 770,
     "_dstBlendFactor": 771,
     "_spriteFrame": {
@@ -10519,8 +10527,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 360,
-      "height": 40
+      "width": 366.86,
+      "height": 113
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -10564,11 +10572,15 @@
       "__id__": 219
     },
     "_enabled": true,
-    "_materials": [],
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
     "_srcBlendFactor": 770,
     "_dstBlendFactor": 771,
-    "_string": "视频结束,感谢支持",
-    "_N$string": "视频结束,感谢支持",
+    "_string": "Video ended, thank \nyou for your support.",
+    "_N$string": "Video ended, thank \nyou for your support.",
     "_fontSize": 40,
     "_lineHeight": 50,
     "_enableWrapText": true,
@@ -10593,7 +10605,11 @@
       "__id__": 214
     },
     "_enabled": true,
-    "_materials": [],
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
     "_srcBlendFactor": 770,
     "_dstBlendFactor": 771,
     "_spriteFrame": {
@@ -11775,8 +11791,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 50,
-      "height": 91
+      "width": 220,
+      "height": 60
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -11831,7 +11847,7 @@
       "__uuid__": "28e187c0-7af4-4ca2-baaf-a0443edd890d"
     },
     "_type": 0,
-    "_sizeMode": 1,
+    "_sizeMode": 0,
     "_fillType": 0,
     "_fillCenter": {
       "__type__": "cc.Vec2",
@@ -11914,7 +11930,11 @@
       "__id__": 248
     },
     "_enabled": true,
-    "_materials": [],
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
     "_srcBlendFactor": 770,
     "_dstBlendFactor": 771,
     "_spriteFrame": {
@@ -11959,7 +11979,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 20,
+      "width": 180,
       "height": 60
     },
     "_anchorPoint": {
@@ -12011,10 +12031,10 @@
     ],
     "_srcBlendFactor": 770,
     "_dstBlendFactor": 771,
-    "_string": "农民",
-    "_N$string": "农民",
-    "_fontSize": 30,
-    "_lineHeight": 30,
+    "_string": "farmer",
+    "_N$string": "farmer",
+    "_fontSize": 27,
+    "_lineHeight": 27,
     "_enableWrapText": true,
     "_N$file": null,
     "_isSystemFontUsed": true,

+ 6 - 4
assets/Script/ATAndroidJS2.ts

@@ -10,9 +10,11 @@ const Cocos2dxHelper = "org/cocos2dx/lib/Cocos2dxHelper";
 const placementID="n1g03bq8qkeckn";
 
 /**
- * 测试专用n6729e95f588aa    n66f7c61b71d4c
+ * 测试专用n6729e95f588aa    n66f7c61b71d4c   
  */
-const testPlacementID="n66f7c61b71d4c"; 
+const testPlacementID="n6729e95f588aa"; 
+
+
 
 
 /**
@@ -181,8 +183,8 @@ const ATAndroidJS: ATAndroidJS = {
     },
     getPlacementID:function(){
        // return placementID;
-        return testPlacementID;
-      // return testPlacementIDForDzk;
+    // return testPlacementID;
+       return testPlacementIDForDzk;
     },
     getDeviceUserId: function(){
         return this.getDeviceId()

+ 2 - 2
assets/Script/controller.js

@@ -43,7 +43,7 @@ cc.Class({
     }
     this.musicManager.init()
     this.lateStart()
-    this.initAdForPage()
+    //this.initAdForPage()
     
   },
 
@@ -109,7 +109,7 @@ cc.Class({
   openPictorial() {
 
      //ZH测试显示AD
-     if(2>1){
+     if(2>3){
       setTimeout(()=>{
         if(ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementID())){
             console.log('zh:AD  ready for controller.js')

+ 101 - 44
assets/Script/game.js

@@ -9,6 +9,13 @@ import   AAJS2  from "./ATAndroidJS2";
 import AESUtil from "./AESUtil"
 
 var AC = require('GameAct')
+//AD播放完毕后需要进行什么奖励的标记,如:fuHuo等,启用游戏的时候需要清空该KEY
+var yxAdMark = 'yxAdMark'
+/**
+ * AD播放完毕标识
+ */
+var adPalyOverEve='adPalyOverEve'
+
 cc.Class({
   extends: cc.Component,
   properties: {
@@ -21,18 +28,69 @@ cc.Class({
     revivePage: cc.Node,
   },
 
+  onLoad () {
+    console.log('zh:1111game.js onload...')
+    cc.sys.localStorage.removeItem(yxAdMark)
+    this.yxAdEventInit();
+  },
+
   start() {
+    console.log('zh:game.js start...')
+
+    console.log('zh: ad over 开始测试发送事件s')
+    this.node.emit(adPalyOverEve, 'test');
+    console.log('zh: ad over 开始测试发送事件e')
+
     this.bindNode()
     this.generatePool()
     this.loadRes()
     this.initAd()
-
   },
 
-      //#region "AD  监听start"
+  //ad相关的事件初始化
+  yxAdEventInit(){
+    let that = this;
+    this.node.on(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 = cc.sys.localStorage.getItem(yxAdMark);//看广告用于 xx 标记
+    console.log('zh:yxAdMark='+mark);
+    switch(mark){
+     case 'fuHuo'://复活
+       console.log('zh:因为你看完了AD,所以开始发放复活道具')
+       this.showReviveSuccess()
+       break;
+     default:
+       console.log('zh:没有找到yxAdMark 相关的信息!!!!!!!')
+       break;
+    }
+    this.clearAdMark();
+  },
+  /**
+   * 清除AD 奖励标识
+   */
+  clearAdMark(){
+    cc.sys.localStorage.removeItem(yxAdMark)
+  },
 
+   //#region "AD  监听start"
 
-      onRewardedVideoAdLoaded(placementId) {
+    onRewardedVideoAdLoaded(placementId) {
         ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdLoaded(" + placementId + ")");
     },
 
@@ -44,8 +102,6 @@ cc.Class({
         // console.log('zh: ad over 开始发送事件aaaa')
         // this.node.emit("handleCustomEvent");
         // console.log('zh: ad over 开始发送事件bbb')
-
-
     },
 
      onRewardedVideoAdPlayStart (placementId, callbackInfo) {
@@ -61,10 +117,9 @@ cc.Class({
         //that.retrive();
        //  BrickMsger.emit(BrickMsger.on_play_sound, 1);
        //  BrickMsger.emit(BrickMsger.on_changeto_start);
-
-        // console.log('zh: ad over 开始发送事件1a')
-        // this.node.emit("handleCustomEvent");
-        // console.log('zh: ad over 开始发送事件OVER2a')
+        console.log('zh: ad onRewardedVideoAdPlayEnd 开始发送事件s')
+        this.node.emit(adPalyOverEve, 'AdPlayEnd');
+        console.log('zh: ad onRewardedVideoAdPlayEnd 发送事件e')
 
 
     },
@@ -80,19 +135,13 @@ cc.Class({
         console.log("onRewardxxxxxxclosed",this.state);
         console.log("zh:onRewardxxxxxxclosed",this.state);
         if(this.state==true){
-        //    console.log('zh: ad over 开始发送事件1')
-        //    this.node.emit("handleCustomEvent");
-        //   console.log('zh: ad over 开始发送事件OVER2')
-
-          
-            // 发射自定义事件
-            // const eventData = new cc.Event.EventCustom('custom-event', false);
-            // eventData.detail = 'Hello from zhdiy!';
-            // this.node.emit('custom-event', eventData);
-            // console.log('zh: ad over 开始发送事件OVER33')
 
+          console.log('zh: ad onRewardedVideoAdClosed 开始发送事件s')
+          this.node.emit(adPalyOverEve, 'AdClosed');
+          console.log('zh: ad onRewardedVideoAdClosed 发送事件e')
+    
        
-            this.state = false;
+          this.state = false;
         }else{
         
           this.state = false;
@@ -135,8 +184,7 @@ cc.Class({
      // 初始化SDK
      //ATSDK.initSDK("h67161678d3fcf", "aa0e53109399d0c3a213140e896bdac07");//正式的,发布提交go0gle play
      //ATSDK.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83");//测试专用,可以显示广告 ???      
-     ATSDK.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e");//这是自己测试专用的
-
+     ATSDK.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e");//这是cccc线上的
 
      ATSDK.setLogDebug(true);
      var GDPRLevel = ATSDK.getGDPRLevel();
@@ -331,31 +379,40 @@ cc.Class({
 
   },
   onReviveButton() {
-    console.log('zh:点击复活按钮3')
-
+    console.log('zh:点击复活按钮1')
+    console.log('zh: 复活BUT 开始测试发送事件1s')
+    cc.sys.localStorage.setItem(yxAdMark, 'fuHuo');//看广告用于 复活 标记
+    this.node.emit(adPalyOverEve, 'AdPlayEnd');
+    console.log('zh: 复活BUT 开始测试发送事件e')
+
+
+    // setTimeout(()=>{
+    //   let placementID = AAJS2.getPlacementID();
+    //   if(ATRewardedVideoSDK.hasAdReady(placementID)){
+    //       cc.sys.localStorage.setItem(yxAdMark, 'fuHuo');//看广告用于 复活 标记
+    //       ATRewardedVideoSDK.showAd(placementID);
+    //   }else{
+    //     cc.sys.localStorage.setItem(yxAdMark, '');
+    //     console.log('zh:AD 没有准备好')
+    //   }
+    // },300)
+
+
+ 
+    // let testMark = false;//无限复活
+    // if(testMark){
+    //   clearInterval(this.reviveTimer)
+    //   this.isRangeAction = false
+    //   if (this._controller.social.node.active) {
+    //     this._controller.social.onReviveButton(1)
+    //   } else {
+    //     this.showReviveSuccess()
+    //   }
+    // }
 
-    setTimeout(()=>{
-      if(ATRewardedVideoSDK.hasAdReady(this.placementID)){
-          ATRewardedVideoSDK.showAd(this.placementID);
-      }else{
-      }
-    },300)
-
-
-  // this.showReviveSuccess()
-    let testMark = false;//无限复活
-    if(testMark){
-      clearInterval(this.reviveTimer)
-      this.isRangeAction = false
-      if (this._controller.social.node.active) {
-        this._controller.social.onReviveButton(1)
-      } else {
-        this.showReviveSuccess()
-      }
-    }
   },
   showReviveSuccess() {
-    console.log('打开复活成功页面')
+    console.log('zh:打开复活成功页面')
     this.revivePage.getChildByName('askRevive').active = false
     this.revivePage.getChildByName('successRevive').active = true
   },

+ 4 - 4
assets/Script/illustrative.js

@@ -28,8 +28,8 @@ cc.Class({
     this.avatar.active = true
     let data = this._controller.gameData.json.levelData[+level - 1]
     let heightScore = this._controller.social.getHighestScore()
-    this.avatar.getChildByName('name').getComponent(cc.Label).string = '历史最高:' + data.name
-    this.avatar.getChildByName('score').getComponent(cc.Label).string = '分数' + heightScore
+    this.avatar.getChildByName('name').getComponent(cc.Label).string = 'Historical highest:' + data.name
+    this.avatar.getChildByName('score').getComponent(cc.Label).string = 'grade:' + heightScore
     setTimeout(() => {
       this._controller.scoreMgr.characterMgr.showAvatarCharacter(+level, this.avatar.getChildByName('db'))
     }, 1000)
@@ -55,11 +55,11 @@ cc.Class({
       card.getChildByName('name').getComponent(cc.Label).string = info.name
       //card.getChildByName('score').getComponent(cc.Label).string = "得分:" + info.score
       card.getChildByName('db').color = cc.Color.WHITE
-      card.getChildByName('giftStep').getComponent(cc.Label).string = "开局奖励" + info.giftStep + "步"
+      card.getChildByName('giftStep').getComponent(cc.Label).string = "Starting bonus" + info.giftStep + "step"
       this._controller.scoreMgr.characterMgr.showCharacter(level + 1, card.getChildByName('db'))
     } else {
       card.getChildByName('name').getComponent(cc.Label).string = '???'
-      card.getChildByName('giftStep').getComponent(cc.Label).string = "开局奖励???步"
+      card.getChildByName('giftStep').getComponent(cc.Label).string = "Starting bonus???step"
       card.getChildByName('db').color = cc.Color.BLACK
       this._controller.scoreMgr.characterMgr.showCharacter(level + 1, card.getChildByName('db'), cc.Color.BLACK)
     }

+ 1 - 1
assets/Script/score.js

@@ -32,7 +32,7 @@ cc.Class({
     this.reviveTime = 0
     this.closeMultLabel()
     this.levelData = g._controller.gameData.json.levelData
-    this.nameLabel.string = "萌心悦"
+    this.nameLabel.string = "MengXinYue"
     this.progressBar.init(0, this.levelData[this.level - 1], this.level)
     this.leftStepLabel.string = this.leftStep
     this.stepAniLabel.node.runAction(cc.hide())

+ 9 - 3
assets/Script/social.js

@@ -95,14 +95,20 @@ cc.Class({
       level: level,
     })
     
-    highLevel = wx.getStorageSync('highLevel')
+    //highLevel = wx.getStorageSync('highLevel')
+
+    highLevel = cc.sys.localStorage.getItem('highLevel')
+
     highLevel = parseInt(highLevel)
     if (highLevel) {
       highLevel = highLevel < level ? level : highLevel
     } else {
       highLevel = level
     }
-    highScore = wx.getStorageSync('highScore')
+    //highScore = wx.getStorageSync('highScore')
+    highScore = cc.sys.localStorage.getItem('highScore')
+
+
     if (highScore) {
       highScore = parseInt(highScore)
       highScore = highScore < score ? score : highScore
@@ -115,7 +121,7 @@ cc.Class({
     //wx.setStorageSync('highScore', highScore + '')
     cc.sys.localStorage.setItem('highLevel', highLevel + '');
     cc.sys.localStorage.setItem('highScore', highScore + '');
-    self._controller.scoreMgr.failHighScore.string = "您的最高分:" + (highScore + '')
+    self._controller.scoreMgr.failHighScore.string = "Your highest score:" + (highScore + '')
     var kvDataList = new Array()
     kvDataList.push({
       key: "highLevel",

+ 22 - 22
assets/gameData.json

@@ -2,112 +2,112 @@
   "动画分数配置": "",
   "levelData": [
     {
-    "name": "萌心悦",
+    "name": "MengXinYue",
     "score": 10000,
     "giftStep":1,
     "step": 5
   }, {
-    "name": "甜梓萱",
+    "name": "TianZixuan",
     "score": 20000,
     "giftStep":2,
     "step": 6
   }, {
-    "name": "梦琪儿",
+    "name": "MengQiEr",
     "score": 25000,
     "giftStep":3,
     "step": 7
   }, {
-    "name": "可心怡",
+    "name": "KeXinYi",
     "score": 30000,
     "giftStep":4,
     "step": 8
   }, {
-    "name": "秋水仙",
+    "name": "QiuShuiYue",
     "score": 35000,
     "giftStep":5,
     "step": 9
   }, {
-    "name": "月清歌",
+    "name": "YueQingGe",
     "score": 45000,
     "giftStep":6,
     "step": 10
   }, {
-    "name": "萌小桃",
+    "name": "MengXiaoTao",
     "score": 55000,
     "giftStep":7,
     "step": 10
   }, {
-    "name": "芷若馨",
+    "name": "ZhiRuoxin",
     "score": 60000,
     "giftStep":8,
     "step": 10
   }, {
-    "name": "心悦诗",
+    "name": "XinYueShi",
     "score": 70000,
     "giftStep":9,
     "step": 10
   }, {
-    "name": "甜蕊儿",
+    "name": "TieXinEr",
     "score": 90000,
     "giftStep":10,
     "step": 10
   }, {
-    "name": "萧玉笛",
+    "name": "XiaoYuDi",
     "score": 100000,
     "giftStep":10,
     "step": 10
   }, {
-    "name": "瑶梦露",
+    "name": "YaoMengLu",
     "score": 150000,
     "giftStep":10,
     "step": 10
   }, {
-    "name": "苏梦蝶",
+    "name": "SuMengDie",
     "score": 200000,
     "giftStep":10,
     "step": 10
   }, {
-    "name": "墨玉轩",
+    "name": "MuYuXuan",
     "score": 250000,
     "giftStep":10,
     "step": 10
   }, {
-    "name": "烟雨梦",
+    "name": "YanYuMeng",
     "score": 300000,
     "giftStep":10,
     "step": 10
   }, {
-    "name": "花满楼",
+    "name": "HuaManLou",
     "score": 350000,
     "giftStep":10,
     "step": 10
   }, {
-    "name": "梅映雪",
+    "name": "MeiYingXue",
     "score": 400000,
     "giftStep":10,
     "step": 10
   }, {
-    "name": "云初霁",
+    "name": "YunChuWu",
     "score": 450000,
     "giftStep":10,
     "step": 10
   }, {
-    "name": "琴心韵",
+    "name": "QinXinYun",
     "score": 500000,
     "giftStep":10,
     "step": 10
   }, {
-    "name": "紫凝香",
+    "name": "ZiNingXiang",
     "score": 550000,
     "giftStep":10,
     "step": 10
   }, {
-    "name": "芷兰心",
+    "name": "ZhiLanXin",
     "score": 600000,
     "giftStep":10,
     "step": 10
   }],
   "buildingData":[{
-    "name":"通天塔"
+    "name":"TongTianTa"
   }]
 }

+ 1 - 1
settings/builder.json

@@ -1,5 +1,5 @@
 {
-  "encryptJs": false,
+  "encryptJs": true,
   "excludeScenes": [],
   "fb-instant-games": {},
   "includeSDKBox": false,