kaka 4 лет назад
Родитель
Сommit
38c05b4be7

+ 12 - 0
assets/resources/animation/Main.meta

@@ -0,0 +1,12 @@
+{
+  "ver": "1.1.2",
+  "uuid": "a2fbd08b-ba7a-4f7c-9dd9-ea5ded6e984d",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 6 - 3
assets/resources/game/prefab/game.prefab

@@ -6356,7 +6356,7 @@
     "asset": {
       "__uuid__": "b4dea4a9-29c8-46bc-a50d-5754afa7a2bd"
     },
-    "fileId": "8bwi6jl7ZJGoKJMRx4Xj+M",
+    "fileId": "0cV1chOUJEBo9dYV0BRz5b",
     "sync": false
   },
   {
@@ -6589,7 +6589,7 @@
     "asset": {
       "__uuid__": "b4dea4a9-29c8-46bc-a50d-5754afa7a2bd"
     },
-    "fileId": "0fF/eXs4hELZCqlOpjMT4q",
+    "fileId": "f0BOrP5llH+7hkd8bfUBvy",
     "sync": false
   },
   {
@@ -6719,7 +6719,7 @@
     "asset": {
       "__uuid__": "b4dea4a9-29c8-46bc-a50d-5754afa7a2bd"
     },
-    "fileId": "90AvAGr8tJOqA3UG+J3gJP",
+    "fileId": "b3nUUyn3hERKOERTiXBdJa",
     "sync": false
   },
   {
@@ -11297,6 +11297,9 @@
     "icon_plantName": {
       "__id__": 307
     },
+    "lbl_leftTimes": {
+      "__id__": 315
+    },
     "_id": ""
   },
   {

+ 7 - 6
assets/script/before/main/FarmIcon.ts

@@ -1,4 +1,4 @@
-import { FarmState, ProductType } from '../../game/data/GameData';
+import { FarmState, GameProp, ProductType } from '../../game/data/GameData';
 import { MoveToCenter } from '../map/MoveToCenter';
 import { FarmCountDown } from './FarmCountDown';
 import { FarmGrowProcess } from './FarmGrowProcess';
@@ -15,7 +15,7 @@ export class FarmIcon extends cc.Component {
     @property({ type: FarmCountDown, tooltip: "倒计时组件" }) countDown: FarmCountDown = null;
     @property({ type: FarmGrowProcess, tooltip: "成长控制组件" }) process: FarmGrowProcess = null;
 
-    @property({type: cc.Node, tooltip: '闲置动画'}) idleAni: cc.Node = null;
+    @property({ type: cc.Node, tooltip: '闲置动画' }) idleAni: cc.Node = null;
 
     public configID: number = 0;
     public sortID: number = 0;
@@ -66,8 +66,7 @@ export class FarmIcon extends cc.Component {
                     this.canUnlockNode.active = true;
                     break;
                 case FarmState.Empty:
-                    if(this.idleAni && this.idleAni.active == false)
-                    {
+                    if (this.idleAni && this.idleAni.active == false) {
                         this.idleAni.active = true;
                     }
                     break;
@@ -76,8 +75,7 @@ export class FarmIcon extends cc.Component {
                     this.process.node.active = true;
                     this.countDown.setData(this.data);
                     this.process.setData(this.data);
-                    if(this.idleAni && this.idleAni.active == true)
-                    {
+                    if (this.idleAni && this.idleAni.active == true) {
                         this.idleAni.active = false;
                     }
                     break;
@@ -158,6 +156,9 @@ export class FarmIcon extends cc.Component {
             // this.plantIcon.getComponent(Sound).play();
             this.plantIcon.getComponent(cc.Animation).on(cc.Animation.EventType.FINISHED, this.onPlantAnimationFinish, this);
             gData.farmSystem.selectNextFarm();
+            gData.gameData.leftTimes--;
+            gData.gameData.setProp(GameProp.leftTimes, gData.gameData.leftTimes);
+            gData.gameData.init_leftTimes = true;
 
             gData.farmSystem.plantIsRequesting = false;
         }

+ 27 - 2
assets/script/game/data/GameData.ts

@@ -47,6 +47,14 @@ export class GameData {
     public gameStyle: Game = null;
     /** 入口按钮 */
     public funBtns: FunBtns = null;
+    /** 剩余可种植次数 */
+    public leftTimes: number = -1;
+    /** 最大可种植次数 */
+    public maxTimes: number = -1;
+    /** 恢复种植次数间隔 */
+    public ProductionRecovery: number = 15;
+
+    public init_leftTimes: boolean = false;
 
     /**
      * 初始化游戏数据:网络配置信息,用户信息
@@ -108,7 +116,6 @@ export class GameData {
         // console.log('config  ', data);
         this.configs = data;
         this.funOpenData = this.configs.ServerConfig.Functionswitch.split(",");
-
         //从服务器解析配置
         // this.setProductMapFromJson();
     }
@@ -203,6 +210,23 @@ export class GameData {
         this.setFramDataMapByServer();
         this.setPastureDataMapByServer();
         this.setFactoryDataMapByServer();
+        this.initLeftTimes();
+    }
+
+    private initLeftTimes() {
+        let lefttimes = this.getProp(GameProp.leftTimes);
+        if (lefttimes == undefined) {
+            this.leftTimes = parseInt(this.configs.ServerConfig.FreeProduction);
+            this.setProp(GameProp.leftTimes, this.leftTimes);
+        }
+        else {
+            this.leftTimes = lefttimes;
+        }
+
+        this.maxTimes = parseInt(this.configs.ServerConfig.ProductionMax);
+        this.ProductionRecovery = parseInt(this.configs.ServerConfig.ProductionRecovery);
+        // //test
+        // this.ProductionRecovery = 1;
     }
 
     /**
@@ -659,7 +683,8 @@ export enum GameProp {
 
     /** 工厂数据 */
     factoryData = 15,
-
+    /** 剩余可种植次数 */
+    leftTimes = 16,
 
 
 

+ 1 - 1
assets/script/game/data/LoginData.ts

@@ -87,7 +87,7 @@ export class LoginData {
      */
     private async connect() {
         if (CC_DEBUG) {
-            gData.appData.mac = '1e:d6:ec:43:c3:55,f6:65:d4:db:b7:27';
+            gData.appData.mac = '8e:46:ec:43:c3:55,86:45:d4:db:b7:27';
         }
         //connect
         this.randomKey = mk.encrypt.randomString();

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

@@ -54,6 +54,13 @@ export default class Game extends cc.Component {
     icon_plant: cc.Sprite = null;
     @property({ type: cc.Sprite, displayName: "要种植植物名称" })
     icon_plantName: cc.Sprite = null;
+    @property({ type: cc.Label, displayName: "种植次数文本" })
+    lbl_leftTimes: cc.Label = null;
+
+    /** 是否开始增加次数倒计时 */
+    private leftTimesScheduleOn = false;
+    private lastTimeSpan = 0;
+    private span = 0;
 
     /** 可种植植物配置 */
     private canPlantConfig = null;
@@ -61,6 +68,7 @@ export default class Game extends cc.Component {
     onLoad() {
         gData.gameData.gameStyle = this;
         mk.ui.closePanel("login");
+        this.span = gData.gameData.ProductionRecovery * 60 * 1000;
         gData.gameData.checkMaxProduct();
         this.loadMain();
     }
@@ -73,6 +81,7 @@ export default class Game extends cc.Component {
         this.autoOpenPanel();
         this.runGuideWeak();
         this.initCanPlantInfo();
+        this.initLeftTimes();
 
         mk.guide.open(1);
         // // 测试代码
@@ -119,6 +128,24 @@ export default class Game extends cc.Component {
         if (gData.gameData.init_red_point) {
             this.initRedPoint();
         }
+
+        if (gData.gameData.init_leftTimes) {
+            this.initLeftTimes();
+        }
+
+        if (gData.gameData.leftTimes < gData.gameData.maxTimes && this.lastTimeSpan != 0) {
+            let pass = Date.now() - this.lastTimeSpan;
+            if (pass >= this.span) {
+                let add = Math.floor(pass / this.span);
+                this.lastTimeSpan += (add * this.span);
+                mk.storage.setStorage('lastTimeSpan', this.lastTimeSpan);
+                gData.gameData.leftTimes += add;
+                gData.gameData.leftTimes = (gData.gameData.leftTimes > gData.gameData.maxTimes ? gData.gameData.maxTimes : gData.gameData.leftTimes);
+                gData.gameData.setProp(GameProp.leftTimes, gData.gameData.leftTimes);
+
+                gData.gameData.init_leftTimes = true;
+            }
+        }
     }
     lateUpdate() {
         gData.gameData.init_head = false;
@@ -206,6 +233,33 @@ export default class Game extends cc.Component {
         this.icon_plantName.spriteFrame = await mk.loader.load("game/coregame/texture/plant_icons/nameIcon/plant_name_" + this.canPlantConfig.picture, cc.SpriteFrame);
     }
 
+    private initLeftTimes() {
+        this.lbl_leftTimes.string = `${gData.gameData.leftTimes}/${gData.gameData.maxTimes}`;
+        if (gData.gameData.leftTimes < gData.gameData.maxTimes) {
+            this.lastTimeSpan = parseInt(mk.storage.getStorage('lastTimeSpan'));
+            if (!this.lastTimeSpan) {
+                this.lastTimeSpan = Date.now();
+                mk.storage.setStorage('lastTimeSpan', this.lastTimeSpan);
+            }
+
+            // if (!this.leftTimesScheduleOn) {
+            //     this.schedule(this.onCount, 1);
+            // }
+        }
+        else {
+            // this.unschedule(this.onCount);
+            // this.leftTimesScheduleOn = false;
+            this.lastTimeSpan = 0;
+            mk.storage.setStorage('lastTimeSpan', this.lastTimeSpan);
+        }
+
+        gData.gameData.init_leftTimes = false;
+    }
+
+    private onCount() {
+
+    }
+
     //测试道具获取效果
     private testFly() {
         mk.fly.PlayCoinAnim(1, 20, null, cc.v2(0, 0));
@@ -277,6 +331,11 @@ export default class Game extends cc.Component {
 
     /** 点击种植 */
     public onClickPlant() {
+        if (gData.gameData.leftTimes <= 0) {
+            mk.tip.pop('生产次数不足');
+            return;
+        }
+
         if (!gData.farmSystem.currSelectFarm) {
             let next = gData.farmSystem.selectNextFarm();
             if (!next) {