Переглянути джерело

Merge branch 'master' of git.mokasz.com:zouyong/team1_nc

wuwangdong 4 роки тому
батько
коміт
e928d636fe

+ 130 - 79
assets/resources/game/prefab/game.prefab

@@ -6994,7 +6994,7 @@
     "asset": {
       "__uuid__": "b4dea4a9-29c8-46bc-a50d-5754afa7a2bd"
     },
-    "fileId": "echjw0C0VGer6JtdWZJMF1",
+    "fileId": "720iDptf5AIY0BNwbBQvnO",
     "sync": false
   },
   {
@@ -7227,7 +7227,7 @@
     "asset": {
       "__uuid__": "b4dea4a9-29c8-46bc-a50d-5754afa7a2bd"
     },
-    "fileId": "50lpOCvopL3I1NJaOGODuF",
+    "fileId": "e6SxevtIBGwbsrJ9dKwbB/",
     "sync": false
   },
   {
@@ -7357,7 +7357,7 @@
     "asset": {
       "__uuid__": "b4dea4a9-29c8-46bc-a50d-5754afa7a2bd"
     },
-    "fileId": "cdGCOybkdAc7xCH+uqBBqw",
+    "fileId": "29bNj+UT5EtY88aAmQHNxr",
     "sync": false
   },
   {
@@ -10755,19 +10755,19 @@
         "__id__": 326
       },
       {
-        "__id__": 330
+        "__id__": 329
       },
       {
-        "__id__": 334
+        "__id__": 333
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 341
+        "__id__": 340
       },
       {
-        "__id__": 342
+        "__id__": 341
       }
     ],
     "_prefab": {
@@ -10804,7 +10804,7 @@
         1,
         1,
         1,
-        1
+        0
       ]
     },
     "_eulerAngles": {
@@ -10847,8 +10847,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 40,
-      "height": 36
+      "width": 175,
+      "height": 173
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -10866,8 +10866,8 @@
         0,
         0,
         1,
-        1,
-        1,
+        0.5,
+        0.5,
         1
       ]
     },
@@ -10900,7 +10900,7 @@
     "_srcBlendFactor": 770,
     "_dstBlendFactor": 771,
     "_spriteFrame": {
-      "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061"
+      "__uuid__": "d28bad6d-ac92-49a6-a9a6-ad6a05f2101c@6c48a"
     },
     "_type": 0,
     "_sizeMode": 1,
@@ -10929,7 +10929,7 @@
   },
   {
     "__type__": "cc.Node",
-    "_name": "植物类型文本",
+    "_name": "植物名称图片",
     "_objFlags": 0,
     "_parent": {
       "__id__": 322
@@ -10939,13 +10939,10 @@
     "_components": [
       {
         "__id__": 327
-      },
-      {
-        "__id__": 328
       }
     ],
     "_prefab": {
-      "__id__": 329
+      "__id__": 328
     },
     "_opacity": 255,
     "_color": {
@@ -10957,8 +10954,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 92,
-      "height": 52.4
+      "width": 47,
+      "height": 23
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -10969,15 +10966,15 @@
       "__type__": "TypedArray",
       "ctor": "Float64Array",
       "array": [
-        12.279,
-        29.821,
+        11,
+        29.337,
         0,
         0,
         0,
         0,
         1,
-        1,
-        1,
+        1.5,
+        1.5,
         1
       ]
     },
@@ -10995,7 +10992,7 @@
     "_id": ""
   },
   {
-    "__type__": "cc.Label",
+    "__type__": "cc.Sprite",
     "_name": "",
     "_objFlags": 0,
     "node": {
@@ -11009,40 +11006,21 @@
     ],
     "_srcBlendFactor": 770,
     "_dstBlendFactor": 771,
-    "_string": "胡萝卜",
-    "_N$string": "胡萝卜",
-    "_fontSize": 30,
-    "_lineHeight": 40,
-    "_enableWrapText": true,
-    "_N$file": null,
-    "_isSystemFontUsed": true,
-    "_spacingX": 0,
-    "_batchAsBitmap": false,
-    "_styleFlags": 1,
-    "_underlineHeight": 0,
-    "_N$horizontalAlign": 1,
-    "_N$verticalAlign": 1,
-    "_N$fontFamily": "Arial",
-    "_N$overflow": 0,
-    "_N$cacheMode": 0,
-    "_id": ""
-  },
-  {
-    "__type__": "cc.LabelOutline",
-    "_name": "",
-    "_objFlags": 0,
-    "node": {
-      "__id__": 326
+    "_spriteFrame": {
+      "__uuid__": "c4b6fba7-64eb-4b94-a7d5-d714cd40516d@6c48a"
     },
-    "_enabled": true,
-    "_color": {
-      "__type__": "cc.Color",
-      "r": 219,
-      "g": 46,
-      "b": 0,
-      "a": 255
+    "_type": 0,
+    "_sizeMode": 1,
+    "_fillType": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
     },
-    "_width": 1,
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_atlas": null,
     "_id": ""
   },
   {
@@ -11053,7 +11031,7 @@
     "asset": {
       "__uuid__": "b4dea4a9-29c8-46bc-a50d-5754afa7a2bd"
     },
-    "fileId": "d1eG7uv+dP26Zqi7XgRsu4",
+    "fileId": "bbn2VTf91DVKFXf9RTVHrb",
     "sync": false
   },
   {
@@ -11067,14 +11045,14 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 331
+        "__id__": 330
       },
       {
-        "__id__": 332
+        "__id__": 331
       }
     ],
     "_prefab": {
-      "__id__": 333
+      "__id__": 332
     },
     "_opacity": 255,
     "_color": {
@@ -11128,7 +11106,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 330
+      "__id__": 329
     },
     "_enabled": true,
     "_materials": [
@@ -11161,7 +11139,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 330
+      "__id__": 329
     },
     "_enabled": true,
     "_color": {
@@ -11194,17 +11172,17 @@
     },
     "_children": [
       {
-        "__id__": 335
+        "__id__": 334
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 339
+        "__id__": 338
       }
     ],
     "_prefab": {
-      "__id__": 340
+      "__id__": 339
     },
     "_opacity": 255,
     "_color": {
@@ -11258,20 +11236,20 @@
     "_name": "文本",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 334
+      "__id__": 333
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 336
+        "__id__": 335
       },
       {
-        "__id__": 337
+        "__id__": 336
       }
     ],
     "_prefab": {
-      "__id__": 338
+      "__id__": 337
     },
     "_opacity": 255,
     "_color": {
@@ -11325,7 +11303,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 335
+      "__id__": 334
     },
     "_enabled": true,
     "_materials": [
@@ -11358,7 +11336,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 335
+      "__id__": 334
     },
     "_enabled": true,
     "_color": {
@@ -11387,7 +11365,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 334
+      "__id__": 333
     },
     "_enabled": true,
     "_materials": [
@@ -11458,21 +11436,88 @@
     "_id": ""
   },
   {
-    "__type__": "b8d2cnq+GZLFK30xbLDqr/m",
+    "__type__": "cc.Button",
     "_name": "",
     "_objFlags": 0,
     "node": {
       "__id__": 322
     },
     "_enabled": true,
-    "panel_name": "",
-    "bool_Auth": false,
-    "open_type": 0,
-    "transition_type": 0,
-    "onComplete": [],
+    "_normalMaterial": null,
+    "_grayMaterial": null,
+    "duration": 0.1,
+    "zoomScale": 1.2,
+    "clickEvents": [
+      {
+        "__id__": 342
+      }
+    ],
+    "_N$interactable": true,
+    "_N$enableAutoGrayEffect": false,
+    "_N$transition": 3,
+    "transition": 3,
+    "_N$normalColor": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_N$pressedColor": {
+      "__type__": "cc.Color",
+      "r": 211,
+      "g": 211,
+      "b": 211,
+      "a": 255
+    },
+    "pressedColor": {
+      "__type__": "cc.Color",
+      "r": 211,
+      "g": 211,
+      "b": 211,
+      "a": 255
+    },
+    "_N$hoverColor": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "hoverColor": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_N$disabledColor": {
+      "__type__": "cc.Color",
+      "r": 124,
+      "g": 124,
+      "b": 124,
+      "a": 255
+    },
+    "_N$normalSprite": null,
+    "_N$pressedSprite": null,
+    "pressedSprite": null,
+    "_N$hoverSprite": null,
+    "hoverSprite": null,
+    "_N$disabledSprite": null,
+    "_N$target": null,
     "_id": ""
   },
   {
+    "__type__": "cc.ClickEvent",
+    "target": {
+      "__id__": 1
+    },
+    "component": "",
+    "_componentId": "8760dQYasROwLaLe1idTS07",
+    "handler": "onClickPlant",
+    "customEventData": ""
+  },
+  {
     "__type__": "cc.PrefabInfo",
     "root": {
       "__id__": 1
@@ -11871,6 +11916,12 @@
     "nodeRedPoint": {
       "__id__": 357
     },
+    "icon_plant": {
+      "__id__": 324
+    },
+    "icon_plantName": {
+      "__id__": 327
+    },
     "_id": ""
   },
   {

+ 1 - 1
assets/script/before/main/FarmCountDown.ts

@@ -34,7 +34,7 @@ export class FarmCountDown extends cc.Component {
     update() {
         let now = Date.now();
         if (this.counting && now < this.ripeTime) {
-            let timeString = Util.ParseTime2Format(Math.floor((this.ripeTime - now) * 0.001), 'h:m:s');
+            let timeString = Util.ParseTime2Format(Math.floor((this.ripeTime - now) * 0.001), 'm:s');
             this.normalCount.string = timeString;
             this.normalProgress.progress = 1 - ((this.ripeTime - now) / (this.totleTime * 1000));
         } else if (this.counting && now > this.ripeTime) {

+ 1 - 0
assets/script/before/main/FarmIcon.ts

@@ -164,6 +164,7 @@ export class FarmIcon extends cc.Component {
         this._state = FarmState.Ripe;
         this.data.state = FarmState.Ripe;
         gData.gameData.setFarmDataMap(this.configID, this.data);
+        gData.gameData.addProductMakeTimesById(this.plantID);
     }
 
     private async onPlantAnimationFinish() {

+ 40 - 4
assets/script/game/data/GameData.ts

@@ -1,3 +1,4 @@
+import Util from "../../before/util/Util";
 import FunBtns from "../game/FunBtns";
 import Game from "../game/Game";
 
@@ -281,6 +282,24 @@ export class GameData {
     //刷新农田
     public needFreshArr = [];
 
+    /** 最大可种植植物ID */
+    private _maxCanPlantID = 10003;
+
+    /** 设置最大可种植id 用于判断随机种植植物*/
+    setMaxPlantID(id) {
+        this._maxCanPlantID = id;
+        this.setProp(GameProp.maxCanPlantID, this._maxCanPlantID);
+    }
+
+    getMaxPlantID() {
+        return this._maxCanPlantID;
+    }
+
+    getRandomPlantConfig() {
+        let id = Util.rnd(10001, this._maxCanPlantID);
+        return this.getProductMap(id);
+    }
+
     public setFarmDataMap(id, data, sendToServer = true) {
         this._farmDataMap.set(id, data);
         let len = this._farmData.length;
@@ -294,10 +313,10 @@ export class GameData {
         }
 
         this.needFreshArr.push(id);
-        // //更新到服务器
-        // if (sendToServer) {
-        //     this.setProp(GameProp.farmData, this._farmData);
-        // }
+        //更新到服务器
+        if (sendToServer) {
+            this.setProp(GameProp.farmData, this._farmData);
+        }
     }
 
     public getFarmDataMap(id) {
@@ -325,6 +344,9 @@ export class GameData {
                 this._farmDataMap.set(id, data);
                 id++;
             }
+
+            //第一次初始数据
+            this.setMaxPlantID(this._maxCanPlantID);
             //更新到服务器
             this.setProp(GameProp.farmData, this._farmData);
         }
@@ -399,6 +421,17 @@ export class GameData {
             this._productMakeTimesData.push(data);
         }
 
+        //设置可种植植物最大id
+        let nextID = id + 1;
+        let nextConfig = this.getProductMap(nextID);
+        if (nextConfig) {
+            if (nextConfig.tab == '农作物' && nextID > this.getMaxPlantID()) {
+                if (nextConfig.unlock == 1 && nextConfig.value <= times) {
+                    this.setMaxPlantID(nextID);
+                }
+            }
+        }
+
         this.setProp(GameProp.productMakeTimes, this._productMakeTimesData);
     }
 
@@ -438,6 +471,9 @@ export enum GameProp {
     /** 产品生产次数 */
     productMakeTimes = 12,
 
+    /** 最大可种植id */
+    maxCanPlantID = 13,
+
 
     /** ------------------ 转盘数据 ------------------------------ */
     turnable_leftTimes = 20,

+ 36 - 1
assets/script/game/game/Game.ts

@@ -1,5 +1,5 @@
 import JsbSystem from "../../mk/system/JsbSystem";
-import { DataEventId, GameProp, VideoAdType } from "../data/GameData";
+import { DataEventId, FarmState, GameProp, VideoAdType } from "../data/GameData";
 import FunBtns from "./FunBtns";
 
 const { ccclass, property } = cc._decorator;
@@ -54,6 +54,13 @@ export default class Game extends cc.Component {
     @property({ type: RedPoinNode, displayName: "红点组" })
     nodeRedPoint: RedPoinNode = null;
 
+    @property({ type: cc.Sprite, displayName: "要种植植物图片" })
+    icon_plant: cc.Sprite = null;
+    @property({ type: cc.Sprite, displayName: "要种植植物名称" })
+    icon_plantName: cc.Sprite = null;
+
+    /** 可种植植物配置 */
+    private canPlantConfig = null;
 
     onLoad() {
         gData.gameData.gameStyle = this;
@@ -68,6 +75,7 @@ export default class Game extends cc.Component {
         this.initInfo();
         this.autoOpenPanel();
         this.runGuideWeak();
+        this.initCanPlantInfo();
 
         mk.guide.open(1);
         // // 测试代码
@@ -214,6 +222,12 @@ export default class Game extends cc.Component {
         gData.guideWeakData.enable = true;
     }
 
+    private async initCanPlantInfo() {
+        this.canPlantConfig = gData.gameData.getRandomPlantConfig();
+        this.icon_plant.spriteFrame = await mk.loader.load("game/coregame/texture/plant_icons/plantIcon_" + this.canPlantConfig.picture, cc.SpriteFrame);
+        this.icon_plantName.spriteFrame = await mk.loader.load("game/coregame/texture/plant_icons/nameIcon/plant_name_" + this.canPlantConfig.picture, cc.SpriteFrame);
+    }
+
     //测试道具获取效果
     private testFly() {
         mk.fly.PlayCoinAnim(1, 20, null, cc.v2(0, 0));
@@ -282,5 +296,26 @@ export default class Game extends cc.Component {
         }
         JsbSystem.sharePic();
     }
+
+    /** 点击种植 */
+    public onClickPlant() {
+        if (!gData.farmSystem.currSelectFarm) {
+            let next = gData.farmSystem.selectNextFarm();
+            if (!next) {
+                mk.tip.pop('没有空闲的农田');
+                return;
+            }
+        }
+
+        if (gData.farmSystem.currSelectFarm) {
+            if (gData.farmSystem.currSelectFarm.state != FarmState.Empty) {
+                mk.tip.pop('没有空闲的农田');
+                return;
+            }
+        }
+
+        gData.farmSystem.plant(this.canPlantConfig.picture);
+        this.initCanPlantInfo();
+    }
 }
 

+ 12 - 12
assets/script/mk/system/TipSystem.ts

@@ -39,9 +39,9 @@ export default class TipSystem extends cc.Component {
      * @param type 弹窗类型 0正常中间弹 1弹到最顶上
      */
     public async pop(str: string, type: number = 0) {
-        let node = await mk.pool.getPrefab("game/prefab/tips");
-        let node_bg = node.getChildByName("bg");
-        let node_lbl = node.getChildByName("lbl");
+        let tipNode = await mk.pool.getPrefab("game/prefab/tips");
+        let node_bg = tipNode.getChildByName("bg");
+        let node_lbl = tipNode.getChildByName("lbl");
         let lbl = node_lbl.getComponent(cc.Label);
         // node_bg.color = this.bg_color;
         // node_bg.opacity = this.bg_opacity;
@@ -49,29 +49,29 @@ export default class TipSystem extends cc.Component {
         lbl.fontSize = this.tip_size;
         lbl.string = str;
         node_bg.width = node_lbl.width + 20 < 200 ? 200 : node_lbl.width + 20;
-        node.width = node_bg.width;
+        tipNode.width = node_bg.width;
         node_bg.height = node_lbl.height + 2;
-        node.parent = this.node;
-        node.x = this.src_x;
-        node.y = this.src_y;
+        tipNode.parent = this.node;
+        tipNode.x = this.src_x;
+        tipNode.y = this.src_y;
         if (type == 0) {
-            cc.tween(node)
+            cc.tween(tipNode)
                 .to(this.tween_time, { x: this.tar_x, y: this.tar_y })
                 .call(() => {
-                    mk.pool.return("tips", node);
+                    mk.pool.return("tips", tipNode);
                 }, this)
                 .start();
         }
         else {
             this.tween_time = 1;
-            node.y = 400;
+            tipNode.y = 400;
             this.tar_y = 520;
 
-            cc.tween(node)
+            cc.tween(tipNode)
                 .to(this.tween_time, { x: this.tar_x, y: this.tar_y })
                 .delay(2)
                 .call(() => {
-                    mk.pool.return("tips", node);
+                    mk.pool.return("tips", tipNode);
                 }, this)
                 .start();
         }