lichao 7 months ago
parent
commit
46fe218a3b
5 changed files with 714 additions and 359 deletions
  1. BIN
      assets/res/AdPlayer.png
  2. 38 0
      assets/res/AdPlayer.png.meta
  3. 509 303
      assets/scenes/game.fire
  4. 148 29
      assets/scripts/game_main.ts
  5. 19 27
      assets/scripts/level_mgr.ts

BIN
assets/res/AdPlayer.png


+ 38 - 0
assets/res/AdPlayer.png.meta

@@ -0,0 +1,38 @@
+{
+  "ver": "2.3.7",
+  "uuid": "bbf3e207-e745-4276-b441-2ba409c9ac2d",
+  "importer": "texture",
+  "type": "sprite",
+  "wrapMode": "clamp",
+  "filterMode": "bilinear",
+  "premultiplyAlpha": false,
+  "genMipmaps": false,
+  "packable": true,
+  "width": 200,
+  "height": 200,
+  "platformSettings": {},
+  "subMetas": {
+    "AdPlayer": {
+      "ver": "1.0.6",
+      "uuid": "798f56e9-4ec9-42d0-86be-61b93c1dfe0b",
+      "importer": "sprite-frame",
+      "rawTextureUuid": "bbf3e207-e745-4276-b441-2ba409c9ac2d",
+      "trimType": "auto",
+      "trimThreshold": 1,
+      "rotated": false,
+      "offsetX": 0,
+      "offsetY": 0,
+      "trimX": 0,
+      "trimY": 0,
+      "width": 200,
+      "height": 200,
+      "rawWidth": 200,
+      "rawHeight": 200,
+      "borderTop": 0,
+      "borderBottom": 0,
+      "borderLeft": 0,
+      "borderRight": 0,
+      "subMetas": {}
+    }
+  }
+}

File diff suppressed because it is too large
+ 509 - 303
assets/scenes/game.fire


+ 148 - 29
assets/scripts/game_main.ts

@@ -74,6 +74,18 @@ export default class NewClass extends cc.Component {
     @property(cc.Node)
     levels_view: cc.Node = null
 
+    @property(cc.Node)
+    hint_ad_player_icon: cc.Node = null
+
+    @property(cc.Node)
+    undo_ad_player_icon: cc.Node = null
+
+    @property(cc.Node)
+    shuffles_ad_player_icon: cc.Node = null
+
+    @property(cc.Node)
+    moveup_ad_player_icon: cc.Node = null
+
 
     //minzindex
     minZindex: number = 10000
@@ -81,16 +93,37 @@ export default class NewClass extends cc.Component {
     progress_levelBase_org = 0.0002
 
 
-
-
     protected onLoad(): void {
         this.initAd();
+
+        // 初始化广告播放图标
+        if (global_model.game.shuffle_counter === 0) {
+            this.shuffles_ad_player_icon.active = true
+        } else {
+            this.shuffles_ad_player_icon.active = false
+        }
+        if (global_model.game.undo_counter === 0) {
+            this.undo_ad_player_icon.active = true
+        } else {
+            this.undo_ad_player_icon.active = false
+        }
+        if (global_model.game.hint_tip_counter === 0) {
+            this.hint_ad_player_icon.active = true
+        } else {
+            this.hint_ad_player_icon.active = false
+        }
+        if (global_model.game.move_up_counter === 0) {
+            this.moveup_ad_player_icon.active = true
+        } else {
+            this.moveup_ad_player_icon.active = false
+        }
+
+
         if (cc.sys.platform == cc.sys.IPAD) {
             cc.find("Canvas").getComponent(cc.Canvas).fitHeight = true
             cc.find("Canvas").getComponent(cc.Canvas).fitWidth = true
         }
         cc.systemEvent.on(game_constants.select_level_clicked, this.select_level_clicked, this)
-
     }
     initAd() {
         console.log('lichao: initAd Success')
@@ -151,13 +184,25 @@ export default class NewClass extends cc.Component {
 
         let customerOption = cc.sys.localStorage.getItem("customerOption");
         if (customerOption === "shuffle") {
-            global_model.game.shuffle_counter++
+            global_model.game.shuffle_counter += 3
+            global_model.save()
+            this.updateItemView()
+            this.shuffles_ad_player_icon.active = false
         } else if (customerOption === "revoke") {
-            global_model.game.undo_counter++
+            global_model.game.undo_counter += 3
+            global_model.save()
+            this.updateItemView()
+            this.undo_ad_player_icon.active = false
         } else if (customerOption === "auto") {
-            global_model.game.hint_tip_counter++
+            global_model.game.hint_tip_counter += 3
+            global_model.save()
+            this.updateItemView()
+            this.hint_ad_player_icon.active = false
         } else if (customerOption === "clearTopThree") {
-            global_model.game.move_up_counter++
+            global_model.game.move_up_counter += 3
+            global_model.save()
+            this.updateItemView()
+            this.moveup_ad_player_icon.active = false
         }
 
         this.updateItemView()
@@ -168,20 +213,26 @@ export default class NewClass extends cc.Component {
     }
     onRewardedVideoAdClosed(placementId, callbackInfo) {
         ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdClosed(" + placementId + ", " + callbackInfo + ")");
-
-        // let customerOption = cc.sys.localStorage.getItem("customerOption");
-        // if (customerOption === "shuffle") {
-        //     global_model.game.shuffle_counter++
-        // } else if (customerOption === "revoke") {
-        //     global_model.game.undo_counter++
-        // } else if (customerOption === "auto") {
-        //     global_model.game.hint_tip_counter++
-        // } else if (customerOption === "clearTopThree") {
-        //     global_model.game.move_up_counter++
-        // }
-
-        // this.updateItemView()
-
+        if (global_model.game.shuffle_counter === 0) {
+            this.shuffles_ad_player_icon.active = true
+        } else {
+            this.shuffles_ad_player_icon.active = false
+        }
+        if (global_model.game.undo_counter === 0) {
+            this.undo_ad_player_icon.active = true
+        } else {
+            this.undo_ad_player_icon.active = false
+        }
+        if (global_model.game.hint_tip_counter === 0) {
+            this.hint_ad_player_icon.active = true
+        } else {
+            this.hint_ad_player_icon.active = false
+        }
+        if (global_model.game.move_up_counter === 0) {
+            this.moveup_ad_player_icon.active = true
+        } else {
+            this.moveup_ad_player_icon.active = false
+        }
     }
     onRewardedVideoAdPlayClicked(placementId, callbackInfo) {
         ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayClicked(" + placementId + ", " + callbackInfo + ")");
@@ -569,11 +620,19 @@ export default class NewClass extends cc.Component {
     }
     click_shuffle() {
         //this.playSFX(this.btn_click)
-        if (global_model.game.shuffle_counter > 0) {
+        if (global_model.game.shuffle_counter > 1) {
+            global_model.game.shuffle_counter--
+            global_model.save()
+            this.updateItemView()
+            this.shuffle()
+            this.shuffles_ad_player_icon.active = false
+        } else if (global_model.game.shuffle_counter === 1) {
             global_model.game.shuffle_counter--
             global_model.save()
             this.updateItemView()
             this.shuffle()
+            // 广告播放图标
+            this.shuffles_ad_player_icon.active = true
         } else {
 
             // 防抖代码
@@ -607,10 +666,17 @@ export default class NewClass extends cc.Component {
                         console.log('lichao:  播放广告3')
                     } else {
                         console.log('lichao:  播放广告4');
-                        global_model.game.shuffle_counter++
+                        this.shuffles_ad_player_icon.active = false
+                        global_model.game.shuffle_counter += 3
+                        global_model.save()
                         this.updateItemView()
                     }
                 }, 300)
+            } else {
+                this.shuffles_ad_player_icon.active = false
+                global_model.game.shuffle_counter += 3
+                global_model.save()
+                this.updateItemView()
             }
 
             if (this.lock) return
@@ -663,11 +729,19 @@ export default class NewClass extends cc.Component {
 
             return
         }
-        if (global_model.game.undo_counter > 0) {
+        if (global_model.game.undo_counter > 1) {
             global_model.game.undo_counter--
             global_model.save()
             this.updateItemView()
             this.undo_operator()
+            this.undo_ad_player_icon.active = false
+        } else if (global_model.game.undo_counter === 1) {
+            global_model.game.undo_counter--
+            global_model.save()
+            this.updateItemView()
+            this.undo_operator()
+            // 广告播放图标
+            this.undo_ad_player_icon.active = true
         } else {
 
             // 防抖代码
@@ -701,10 +775,18 @@ export default class NewClass extends cc.Component {
                         console.log('lichao:  播放广告3')
                     } else {
                         console.log('lichao:  播放广告4');
-                        global_model.game.undo_counter++
+                        global_model.game.undo_counter += 3
+                        global_model.save()
                         this.updateItemView()
+                        this.undo_ad_player_icon.active = false
+
                     }
                 }, 300)
+            } else {
+                global_model.game.undo_counter += 3
+                global_model.save()
+                this.updateItemView()
+                this.undo_ad_player_icon.active = false
             }
 
             if (this.lock) return
@@ -732,11 +814,20 @@ export default class NewClass extends cc.Component {
     }
     click_hint() {
         //this.playSFX(this.btn_click)
-        if (global_model.game.hint_tip_counter > 0) {
+        if (global_model.game.hint_tip_counter > 1) {
             global_model.game.hint_tip_counter--
             global_model.save()
             this.updateItemView()
             this.searchRemoveable()
+            // this.hintNodeInstance.dispatchEvent(new cc.Event.EventCustom("adIconEnableHint", true));
+            this.hint_ad_player_icon.active = false
+        } else if (global_model.game.hint_tip_counter === 1) {
+            global_model.game.hint_tip_counter--
+            global_model.save()
+            this.updateItemView()
+            this.searchRemoveable()
+            // 广告播放图标
+            this.hint_ad_player_icon.active = true
         } else {
 
             // 防抖代码
@@ -772,10 +863,19 @@ export default class NewClass extends cc.Component {
                         console.log('lichao:  播放广告3')
                     } else {
                         console.log('lichao:  播放广告4');
-                        global_model.game.hint_tip_counter++
+                        this.hint_ad_player_icon.active = false
+
+                        global_model.game.hint_tip_counter += 3
+                        global_model.save()
                         this.updateItemView()
                     }
                 }, 300)
+            } else {
+                global_model.game.hint_tip_counter += 3
+                this.hint_ad_player_icon.active = false
+
+                global_model.save()
+                this.updateItemView()
             }
 
             if (this.lock) return
@@ -792,13 +892,23 @@ export default class NewClass extends cc.Component {
 
             return
         }
-        if (global_model.game.move_up_counter > 0) {
+        if (global_model.game.move_up_counter > 1) {
+            global_model.game.move_up_counter--
+            global_model.save()
+            this.updateItemView()
+
+            //放三个 块上去最左边的三个块放上去
+            this.moveup3_elements()
+            this.moveup_ad_player_icon.active = false
+        } else if (global_model.game.move_up_counter === 1) {
             global_model.game.move_up_counter--
             global_model.save()
             this.updateItemView()
 
             //放三个 块上去最左边的三个块放上去
             this.moveup3_elements()
+            // 广告播放图标
+            this.moveup_ad_player_icon.active = true
         } else {
 
             // 防抖代码
@@ -832,10 +942,19 @@ export default class NewClass extends cc.Component {
                         console.log('lichao:  播放广告3')
                     } else {
                         console.log('lichao:  播放广告4');
-                        global_model.game.move_up_counter++
+                        this.moveup_ad_player_icon.active = false
+
+                        global_model.game.move_up_counter += 3
+                        global_model.save()
                         this.updateItemView()
                     }
                 }, 300)
+            } else {
+                this.moveup_ad_player_icon.active = false
+
+                global_model.game.move_up_counter += 3
+                global_model.save()
+                this.updateItemView()
             }
 
             if (this.lock) return

+ 19 - 27
assets/scripts/level_mgr.ts

@@ -1,4 +1,4 @@
-const {ccclass, property} = cc._decorator;
+const { ccclass, property } = cc._decorator;
 import game_constants from "./game_constants";
 import global_model from "./global_model";
 import level_item from "./level_item"
@@ -23,43 +23,35 @@ export default class NewClass extends cc.Component {
     @property(cc.Node)
     page6: cc.Node = null;
 
-    AllLvItems:level_item[]=[]
+    AllLvItems: level_item[] = []
 
-    onLoad () 
-    {
-        this.page1.children.forEach(v=>
-        {
+    onLoad() {
+        this.page1.children.forEach(v => {
             this.AllLvItems.push(v.getComponent(level_item))
         })
-        this.page2.children.forEach(v=>
-        {
+        this.page2.children.forEach(v => {
             this.AllLvItems.push(v.getComponent(level_item))
         })
-        this.page3.children.forEach(v=>
-        {
+        this.page3.children.forEach(v => {
             this.AllLvItems.push(v.getComponent(level_item))
         })
-        this.page4.children.forEach(v=>
-        {
+        this.page4.children.forEach(v => {
             this.AllLvItems.push(v.getComponent(level_item))
         })
-        this.page5.children.forEach(v=>
-            {
-                this.AllLvItems.push(v.getComponent(level_item))
-            })
-        this.page6.children.forEach(v=>
-            {
-                this.AllLvItems.push(v.getComponent(level_item))
-            })
-        let currentLv=global_model.game.level
-        this.AllLvItems.forEach((v,idx)=>{
-            v.initLevelItem(idx+1,idx+1 == currentLv ,idx+1>currentLv)
+        this.page5.children.forEach(v => {
+            this.AllLvItems.push(v.getComponent(level_item))
+        })
+        this.page6.children.forEach(v => {
+            this.AllLvItems.push(v.getComponent(level_item))
+        })
+        let currentLv = global_model.game.level
+        this.AllLvItems.forEach((v, idx) => {
+            v.initLevelItem(idx + 1, idx + 1 == currentLv, idx + 1 > currentLv)
         })
-        cc.systemEvent.on(game_constants.select_level_clicked,this.closeLvView,this)
+        cc.systemEvent.on(game_constants.select_level_clicked, this.closeLvView, this)
     }
-    closeLvView()
-    {
-        this.node.active=false
+    closeLvView() {
+        this.node.active = false
 
     }
 

Some files were not shown because too many files changed in this diff