wuwangdong 4 lat temu
rodzic
commit
7b2f611878
1 zmienionych plików z 20 dodań i 7 usunięć
  1. 20 7
      assets/script/game/data/GameData.ts

+ 20 - 7
assets/script/game/data/GameData.ts

@@ -980,10 +980,15 @@ export class GameData {
     }
 
     //根据tab获取最大id的数据
-    public getMaxProductDataByType(type: ProductType){
+    public getMaxProductDataByType(type: ProductType, id){
         let arr = this._productTypeMap.get(type);
         let len = arr.length;
-        return arr[len - 1];
+        if(arr[len - 1].picture >= id)
+        {
+            return this.getProductMap(id);
+        }else{
+            return null;
+        }      
     }
 
     /** 产品生产/种植次数 服务器数据 */
@@ -1032,6 +1037,8 @@ export class GameData {
             this._productMakeTimesMap.set(this._productMakeTimesData.makeTimes[i].id, this._productMakeTimesData.makeTimes[i].times);
             this.setMaxProduct(this._productMakeTimesData.makeTimes[i].id);
         }
+
+        this.judgeAddExtraUnlockMaxId();
     }
 
     addProductMakeTimesById(id: number) {
@@ -1139,21 +1146,27 @@ export class GameData {
         if(this._productMakeTimesData.productUnlockMaxId)
         {
             let data = this._productMakeTimesData.productUnlockMaxId;
-
+            let isUpdateToSever = false;
             data.forEach((value, key) => {
                 if(key != ProductType.dw)
                 {
-                    let data = this.getMaxProductDataByType(key);
-                    if(data.unlock == 1 && value < data.picture)
+                    let product = this.getMaxProductDataByType(key, value + 1);
+                    if(product && product.unlock == 1)
                     {
                         let makeTimes = this.getProductMakeTimesById(value);
-                        if(makeTimes >= data.value)
+                        if(makeTimes >= product.value)
                         {
-                            this.addProductUnlockMaxId(key, data.picture, false);
+                            this.addProductUnlockMaxId(key, product.picture, false);
+                            isUpdateToSever = true;
                         }
                     }
                 }    
             });
+
+            if(isUpdateToSever)
+            {
+                this.updateDataToSever();
+            }
         }
     }