wuwangdong 4 лет назад
Родитель
Сommit
f116b0102c

+ 26 - 11
assets/resources/game/prefab/game.prefab

@@ -2258,7 +2258,7 @@
         "__id__": 61
       }
     ],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 64
@@ -2395,8 +2395,8 @@
     "_dstBlendFactor": 771,
     "_string": "种植5次玉米胡萝卜解锁",
     "_N$string": "种植5次玉米胡萝卜解锁",
-    "_fontSize": 20,
-    "_lineHeight": 20,
+    "_fontSize": 30,
+    "_lineHeight": 30,
     "_enableWrapText": true,
     "_N$file": null,
     "_isSystemFontUsed": true,
@@ -2483,7 +2483,7 @@
         "__id__": 85
       }
     ],
-    "_active": false,
+    "_active": true,
     "_components": [],
     "_prefab": {
       "__id__": 97
@@ -3614,10 +3614,12 @@
   },
   {
     "__type__": "cc.ClickEvent",
-    "target": null,
+    "target": {
+      "__id__": 1
+    },
     "component": "",
-    "_componentId": "9b578CB5kBCtpyvrx1EoT+t",
-    "handler": "clickUnGetRewardBtn",
+    "_componentId": "8760dQYasROwLaLe1idTS07",
+    "handler": "clickGetFarmMapRewardBtn",
     "customEventData": ""
   },
   {
@@ -7398,7 +7400,7 @@
     "asset": {
       "__uuid__": "b4dea4a9-29c8-46bc-a50d-5754afa7a2bd"
     },
-    "fileId": "6a5cmY2LpG+aFjnXARPpWH",
+    "fileId": "08DLIJJttIo5p3NzlRj7+5",
     "sync": false
   },
   {
@@ -7610,7 +7612,7 @@
     "asset": {
       "__uuid__": "b4dea4a9-29c8-46bc-a50d-5754afa7a2bd"
     },
-    "fileId": "4fj1oQKHhKu57GIKAFVNY5",
+    "fileId": "38QVntNk5B87OzZ4MoAszm",
     "sync": false
   },
   {
@@ -7719,7 +7721,7 @@
     "asset": {
       "__uuid__": "b4dea4a9-29c8-46bc-a50d-5754afa7a2bd"
     },
-    "fileId": "c1SqrdFXZF46YXr5A1pOVd",
+    "fileId": "36wPkal3lNTKpHISWuttIe",
     "sync": false
   },
   {
@@ -10985,7 +10987,20 @@
     "lbl_farmMapDes": {
       "__id__": 62
     },
-    "lbl_value": [],
+    "lbl_value": [
+      {
+        "__id__": 72
+      },
+      {
+        "__id__": 75
+      },
+      {
+        "__id__": 78
+      },
+      {
+        "__id__": 81
+      }
+    ],
     "_id": ""
   },
   {

+ 6 - 0
assets/script/game/data/GameData.ts

@@ -701,6 +701,7 @@ export class GameData {
     }
 
     addProductMakeTimesById(id: number) {
+        let isAddMaxProduct = false;
         let times = this._productMakeTimesMap.get(id);
         if (!times) {
             times = 0;
@@ -737,6 +738,7 @@ export class GameData {
         if (nextConfig) {
             if (nextConfig.tab == curConfig.tab && nextID > this.getMaxProduct(curConfig.tab)) {
                 if (nextConfig.unlock == 1 && nextConfig.value <= times) {
+                    isAddMaxProduct = true;
                     this._productMakeTimesMap.set(nextID, 0);
                     let data = { 'id': nextID, 'times': 0 };
                     this._productMakeTimesData.push(data);
@@ -749,6 +751,10 @@ export class GameData {
             }
         }
 
+        if(!isAddMaxProduct)
+        {
+            mk.event.emit("refreshFarmMapUI");
+        }
         this.setProp(GameProp.productMakeTimes, this._productMakeTimesData);
     }
 

+ 132 - 18
assets/script/game/game/Game.ts

@@ -1,6 +1,6 @@
 import Util from "../../before/util/Util";
 import JsbSystem from "../../mk/system/JsbSystem";
-import { RateConfig } from "../data/AdData";
+import { AdFun, RateConfig } from "../data/AdData";
 import { DataEventId, GameProp, ProductType, VideoAdType } from "../data/GameData";
 
 const { ccclass, property } = cc._decorator;
@@ -121,6 +121,8 @@ export default class Game extends cc.Component {
             }
         }
 
+        this.initRefreshEvent();
+
     }
 
     start() {
@@ -203,6 +205,14 @@ export default class Game extends cc.Component {
                 mk.ui.openPanel('module/speedUpUI/restoreProductTimes');
             }
         }
+
+        if (this.startTimes) {
+            this.btnCD += dt;
+            if (this.btnCD >= 1) {
+                this.startTimes = false;
+                this.btnCD = 0;
+            }
+        }
     }
     lateUpdate() {
         gData.gameData.init_head = false;
@@ -590,8 +600,18 @@ export default class Game extends cc.Component {
     //图鉴部分logic
     public initRefreshEvent() {
 
+        mk.event.register("initFarmMapUi", this.initFarmMapUi.bind(this), this);
+        mk.event.register("refreshFarmMapUI", this.refreshFarmMapUI.bind(this), this);
+
+
+        this.initFarmMapUi();
+
+        this.showChangePart();
     }
 
+    private uiShowType = 3;
+    private productType = ProductType.nzw;
+    private productIndex = 0;
     public async initFarmMapUi() {
         let plantPath = '';
         let namePath = '';
@@ -605,27 +625,37 @@ export default class Game extends cc.Component {
         }
 
         //1:有可领奖的,2:正在解锁,3:所有奖励都领取完
-        let uiShowType = 3;
+        this.uiShowType = 3;
         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]));
+                    let data = list_data[i];
+                    if (data.picture <= max) {
+                        let state = gData.gameData.getFarmMapRewardState(this.getIndex(data));
                         if (state == 0) {
-                            uiShowType = 1;
-
-                            this.sp_farmMapIcon.spriteFrame = await mk.loader.load(plantPath + list_data[i].picture, cc.SpriteFrame);
+                            this.uiShowType = 1;
+                            this.productType = ProductType[key];
+                            this.productIndex = i;
+
+                            this.node_farmMapGetReward.active = true;
+                            this.node_farmMapProduct.active = false;
+                            this.node_farmMapUI.active = true;
+                            this.sp_farmMapIcon.spriteFrame = await mk.loader.load(plantPath + data.picture, cc.SpriteFrame);
                             return;
                         }
-                    } else if (list_data[i].picture - 1 == max) {
-                        uiShowType = 2
-
-                        let times = gData.gameData.getProductMakeTimesById(list_data[i].picture - 1);
-                        let plantName = gData.gameData.getProductMap(list_data[i].picture - 1).name;
-                        let des = this.getDesByType(list_data[i]);
-                        this.lbl_farmMapDes.string = `${des}${list_data[i].value}次${plantName}(${times}/${list_data[i].value})`;;
+                    } else if (data.picture - 1 == max) {
+                        this.uiShowType = 2
+                        this.productType = ProductType[key];
+                        this.productIndex = i;
+                        this.node_farmMapGetReward.active = false;
+                        this.node_farmMapProduct.active = true;
+                        this.node_farmMapUI.active = true;
+                        let times = gData.gameData.getProductMakeTimesById(data.picture - 1);
+                        let plantName = gData.gameData.getProductMap(data.picture - 1).name;
+                        let des = this.getDesByType(data);
+                        this.lbl_farmMapDes.string = `${des}${data.value}次${plantName}(${times}/${data.value})`;
                         this.sp_farmMapIcon.spriteFrame = await mk.loader.load('module/farmMap/texture/gift', cc.SpriteFrame);
                         return;
                     }
@@ -633,14 +663,56 @@ export default class Game extends cc.Component {
             }
         }
 
-        if (uiShowType == 3) {
+        if (this.uiShowType == 3) {
             this.node_farmMapUI.active = false;
+        }
+    }
+
+    public refreshFarmMapUI() {
+        if (this.uiShowType == 2) {
+            let list_data = gData.gameData.getProductArrByType(this.productType);
+            let data = list_data[this.productIndex];
+
+            let times = gData.gameData.getProductMakeTimesById(data.picture - 1);
+            let plantName = gData.gameData.getProductMap(data.picture - 1).name;
+            let des = this.getDesByType(data);
+            this.lbl_farmMapDes.string = `${des}${data.value}次${plantName}(${times}/${data.value})`;;
+        }
+    }
+
+    private btnCD = 0;
+    private startTimes = false;
+    public clickGetFarmMapRewardBtn() {
+
+        if (!this.startTimes) {
+            this.startTimes = true;
+            this.btnCD = 0;
         } else {
-            if (!this.node_farmMapUI.active) {
-                this.node_farmMapUI.active = true;
-            }
+            return;
         }
 
+        mk.audio.playEffect("button");
+
+        mk.ad.videoAdType = VideoAdType.video_init_6;
+        mk.ad.watchAd(async (success) => {
+            if (success) {
+                await gData.adData.watchVideo(AdFun.farmMap);
+
+                if (gData.farmMapData.init_award) {
+
+                    gData.farmMapData.init_award = false;
+                    gData.reward.adData = gData.farmMapData.adData;
+                    mk.ui.openPanel('module/reward/reward');
+                    
+                    gData.farmMapData.isStateChange = true;
+                    let list_data = gData.gameData.getProductArrByType(this.productType);
+                    let data = list_data[this.productIndex];
+                    gData.gameData.setFarmMapRewardState(this.getIndexExtra(data), 1);
+
+                    this.initFarmMapUi();
+                }
+            }
+        })
     }
 
     showChangePart() {
@@ -696,6 +768,48 @@ export default class Game extends cc.Component {
         return index;
     }
 
+    getIndexExtra(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;
+    }
+
     getDesByType(data) {
         let des = ''
         switch (data.tab) {

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

@@ -19,6 +19,8 @@ export class RedPointControl extends cc.Component {
         if(gData.farmMapData.isStateChange)
         {
             this.changeStatus();
+
+            mk.event.emit("initFarmMapUi");
         }
 
         if(gData.farmMapData.isInit)
@@ -28,6 +30,11 @@ export class RedPointControl extends cc.Component {
         }
     }
 
+    lateUpdate()
+    {
+        gData.farmMapData.isStateChange = false;
+    }
+
     private changeStatus()
     {
         for (let key in ProductType) {

+ 0 - 5
assets/script/game/module/farmMap/FarmMap.ts

@@ -94,11 +94,6 @@ export default class FarmMap extends cc.Component {
         }
     }
 
-    lateUpdate()
-    {
-        gData.farmMapData.isStateChange = false;
-    }
-
     getIndex(data) {
         let index: any = {};
         index.i = 0;