wuwangdong преди 4 години
родител
ревизия
e493e81c79

Файловите разлики са ограничени, защото са твърде много
+ 260 - 136
assets/resources/game/coregame/coregame.prefab


+ 2 - 1
assets/script/game/data/AdData.ts

@@ -104,7 +104,8 @@ export class AdData {
     }
 
 
-    public async watchVideo(type: AdFun) {
+    public async watchVideo(type: AdFun)
+    {
         this.ad_subType = type;
         let data = {
             "imei": gData.appData.machineInfo.imei,

+ 85 - 0
assets/script/game/game/RedPointControl.ts

@@ -0,0 +1,85 @@
+import { ProductType } from "../data/GameData";
+
+const { ccclass, property } = cc._decorator;
+
+@ccclass
+export class RedPointControl extends cc.Component {
+
+    @property({type: cc.Node, displayName: '红点节点'})
+    private node_redPoint: cc.Node = null;
+
+    start()
+    {
+        this.changeStatus();
+    }
+
+    update(dt)
+    {
+        if(gData.farmMapData.isStateChange)
+        {
+            this.changeStatus();
+        }
+    }
+
+    private changeStatus()
+    {
+        for (let key in ProductType) {
+            let max = gData.gameData.getMaxProduct(ProductType[key]);
+            if (max) {
+                let list_data = gData.gameData.getProductArrByType(ProductType[key]);        
+                for (let i = 0; i != list_data.length; ++i) {
+                    if (list_data[i].picture <= max) {
+                        let state = gData.gameData.getFarmMapRewardState(this.getIndex(list_data[i]));
+                        if (state == 0) {
+                            this.node_redPoint.active = true;
+                            return;
+                        }
+                    }
+                }
+            }
+        }
+        this.node_redPoint.active = false;
+    }
+
+    getIndex(data) {
+        let index: any = {};
+        index.i = 0;
+        index.j = 0;
+        switch (data.tab) {
+            case '农作物':
+                index.i = 0;
+                index.j = data.picture - 10001;
+                break;
+            case '动物':
+                index.i = 1;
+                index.j = data.picture - 20001;
+                break;
+            case '爆米花厂':
+                index.i = 2;
+                index.j = data.picture - 20004;
+                break;
+            case '糕点铺':
+                index.i = 3;
+                index.j = data.picture - 20013;
+                break;
+            case '制糖厂':
+                index.i = 4;
+                index.j = data.picture - 20010;
+                break;
+            case '炼乳厂':
+                index.i = 5;
+                index.j = data.picture - 20007;
+                break;
+            case '功夫面馆':
+                index.i = 6;
+                index.j = data.picture - 20025;
+                break;
+            case '快餐店':
+                index.i = 7;
+                index.j = data.picture - 20019;
+                break;
+        }
+
+        return index;
+    }
+}

+ 9 - 0
assets/script/game/game/redPointControl.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "ead93920-6192-4fec-8919-f46ab4ebab3d",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 11 - 8
assets/script/game/module/farmMap/FarmItem.ts

@@ -157,16 +157,19 @@ export default class FarmItem extends cc.Component {
         mk.audio.playEffect("button");
 
         mk.ad.videoAdType = VideoAdType.video_init_6;
-        mk.ad.watchAd((success) => {
+        mk.ad.watchAd(async (success) => {
             if (success) {
-                gData.adData.watchVideo(AdFun.farmMap);
+                await gData.adData.watchVideo(AdFun.farmMap);
                 
-                gData.farmMapData.isStateChange = true;
-                this.node_getBtn.active = true;
-                this.node_ungetBtn.active = false;
-                this.node_unluckBtn.active = false;
-                this.node_redPoint.active = false;
-                gData.gameData.setFarmMapRewardState(this.getIndex(), 1);
+                if(gData.farmMapData.init_award)
+                {
+                    gData.farmMapData.isStateChange = true;
+                    this.node_getBtn.active = true;
+                    this.node_ungetBtn.active = false;
+                    this.node_unluckBtn.active = false;
+                    this.node_redPoint.active = false;
+                    gData.gameData.setFarmMapRewardState(this.getIndex(), 1);
+                }        
             }
         })
     }

+ 7 - 3
assets/script/game/module/farmMap/FarmMap.ts

@@ -84,17 +84,21 @@ export default class FarmMap extends cc.Component {
 
     update(dt) {
         if (gData.farmMapData.isStateChange) {
-            this.refreshBtnState();
-            gData.farmMapData.isStateChange = false;
+            this.refreshBtnState();      
         }
 
         if (gData.farmMapData.init_award) {
             gData.farmMapData.init_award = false;
-            gData.reward.data = gData.farmMapData.adData;
+            gData.reward.adData = gData.farmMapData.adData;
             mk.ui.openPanel('module/reward/reward');
         }
     }
 
+    lateUpdate()
+    {
+        gData.farmMapData.isStateChange = false;
+    }
+
     getIndex(data) {
         let index: any = {};
         index.i = 0;

+ 5 - 5
assets/script/game/module/reward/Reward.ts

@@ -66,11 +66,11 @@ export default class Reward extends cc.Component {
         if (gData.reward.add_redbag_value) {
             this.initCashOutStyle(gData.gameData.gameData.redMoney + gData.reward.add_redbag_value);
         }
-        if (gData.reward.adData) {
-            // 展示奖励
-            this.watchVideoCall();
-            return;
-        }
+        // if (gData.reward.adData) {
+        //     // 展示奖励
+        //     this.watchVideoCall();
+        //     return;
+        // }
     }
 
     lateUpdate() {

Някои файлове не бяха показани, защото твърде много файлове са промени