wuwangdong 4 years ago
parent
commit
290feb03ef
2 changed files with 22 additions and 11 deletions
  1. 20 11
      assets/script/game/data/GameData.ts
  2. 2 0
      assets/script/game/game/Game.ts

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

@@ -103,6 +103,9 @@ export class GameData {
     //恢复生产次数
     public restoreProductTimes = 0;
 
+    /** 最大可种植产品可更新到服务器标识 */
+    public maxProductToServer = false;
+
     /**
      * 初始化游戏数据:网络配置信息,用户信息
      * @returns 
@@ -411,23 +414,20 @@ export class GameData {
 
     //提现次数
     public _cashOutTimes = 0;
-    public initCashOutTimes()
-    {
-        let v= this.getProp(GameProp.cashOutTimes);
-        if(v)
-        {
+    public initCashOutTimes() {
+        let v = this.getProp(GameProp.cashOutTimes);
+        if (v) {
             this._cashOutTimes = v;
-        }else{
+        } else {
             this._cashOutTimes = 0;
         }
-        console.log(`initCashOutTimes====>${this._cashOutTimes }`);
+        console.log(`initCashOutTimes====>${this._cashOutTimes}`);
     }
 
-    public addCashOutTimes()
-    {
+    public addCashOutTimes() {
         this._cashOutTimes += 1;
         this.setProp(GameProp.cashOutTimes, this._cashOutTimes);
-        console.log(`addCashOutTimes====>${this._cashOutTimes }`);
+        console.log(`addCashOutTimes====>${this._cashOutTimes}`);
     }
 
     /** 是否是新用户 */
@@ -1028,6 +1028,8 @@ export class GameData {
         }
 
         gData.farmMapData.isStateChange = true;
+
+        this.updateMaxProduct();
     }
 
     /** 农场升级时解锁工厂,检查最大可种植/生产商品 */
@@ -1158,6 +1160,13 @@ export class GameData {
             }
         }
     }
+
+    /** 更新最大可种植产品到服务器 */
+    updateMaxProduct() {
+        if (this.maxProductToServer) {
+            mk.http.sendData('updateMaxProduct', this._maxProduct);
+        }
+    }
 }
 
 /**
@@ -1204,7 +1213,7 @@ export enum GameProp {
 
     //提现次数
     cashOutTimes = 21,
-    
+
 }
 
 /**

+ 2 - 0
assets/script/game/game/Game.ts

@@ -108,6 +108,8 @@ export default class Game extends cc.Component {
         gData.gameData.gameStyle = this;
         this.span = gData.gameData.ProductionRecovery * 60 * 1000;
         gData.gameData.checkTaskFinishUnLock();
+        gData.gameData.maxProductToServer = true;
+        gData.gameData.updateMaxProduct();
         this.registerCallBack();
 
         console.log("===[Jsbsystem 显示开屏广告================================")