소스 검색

增加种田功能

kaka 4 년 전
부모
커밋
986675c210
4개의 변경된 파일168개의 추가작업 그리고 95개의 파일을 삭제
  1. 130 79
      assets/resources/game/prefab/game.prefab
  2. 1 1
      assets/script/before/main/FarmCountDown.ts
  3. 25 3
      assets/script/game/game/Game.ts
  4. 12 12
      assets/script/mk/system/TipSystem.ts

+ 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) {

+ 25 - 3
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,11 @@ 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;
 
@@ -217,9 +222,10 @@ export default class Game extends cc.Component {
         gData.guideWeakData.enable = true;
     }
 
-    private initCanPlantInfo() {
+    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);
     }
 
     //测试道具获取效果
@@ -293,7 +299,23 @@ export default class Game extends cc.Component {
 
     /** 点击种植 */
     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();
         }