woso_javan před 2 měsíci
rodič
revize
882f1c24fa

+ 572 - 0
assets/module_storm_sunder/Prefabs/Blood.prefab

@@ -0,0 +1,572 @@
+[
+  {
+    "__type__": "cc.Prefab",
+    "_name": "Blood",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_native": "",
+    "data": {
+      "__id__": 1
+    },
+    "optimizationPolicy": 0,
+    "persistent": false
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "Blood",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": null,
+    "_children": [
+      {
+        "__id__": 2
+      },
+      {
+        "__id__": 16
+      }
+    ],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 22
+      }
+    ],
+    "_prefab": {
+      "__id__": 24
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 1073741824,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "ProgressBar",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [
+      {
+        "__id__": 3
+      }
+    ],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 9
+      },
+      {
+        "__id__": 11
+      },
+      {
+        "__id__": 13
+      }
+    ],
+    "_prefab": {
+      "__id__": 15
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 1073741824,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "Bar",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 2
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 4
+      },
+      {
+        "__id__": 6
+      }
+    ],
+    "_prefab": {
+      "__id__": 8
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": -150,
+      "y": 0,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 3
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 5
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 180,
+      "height": 15
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "d5PEgOmkVGy64gC633SqVX"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 3
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 7
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 36,
+      "g": 245,
+      "b": 8,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "24a704da-2867-446d-8d1a-5e920c75e09d@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_type": 1,
+    "_fillType": 0,
+    "_sizeMode": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_useGrayscale": false,
+    "_atlas": null,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "ef+YRMUhVJhZ8M/adRn9/B"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "b2DVRdCY1HIL16DSuqSH+l",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 10
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 300,
+      "height": 15
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "d3o2zG8zxMgaiLFs6s1bFU"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 12
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "9fd900dd-221b-4f89-8f2c-fba34243c835@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_type": 1,
+    "_fillType": 0,
+    "_sizeMode": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_useGrayscale": false,
+    "_atlas": null,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "9ewQX7MjJHwr8E5TT9mQqJ"
+  },
+  {
+    "__type__": "cc.ProgressBar",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 14
+    },
+    "_barSprite": {
+      "__id__": 6
+    },
+    "_mode": 0,
+    "_totalLength": 300,
+    "_progress": 0.6,
+    "_reverse": false,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "e5OQfe+F5D+YnPLMqvpKwh"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "3eqqF9JP1G27s8kmpIk+ad",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "LbHp",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 17
+      },
+      {
+        "__id__": 19
+      }
+    ],
+    "_prefab": {
+      "__id__": 21
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 3,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 1073741824,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 16
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 18
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 34.16015625,
+      "height": 50.4
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "b0kugGvL9KW6f7vgPI1G+g"
+  },
+  {
+    "__type__": "cc.Label",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 16
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 20
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_string": "100",
+    "_horizontalAlign": 1,
+    "_verticalAlign": 1,
+    "_actualFontSize": 20,
+    "_fontSize": 20,
+    "_fontFamily": "Arial",
+    "_lineHeight": 40,
+    "_overflow": 0,
+    "_enableWrapText": false,
+    "_font": {
+      "__uuid__": "23a47957-4ba6-41f7-999f-a5fbf8a48aed",
+      "__expectedType__": "cc.TTFFont"
+    },
+    "_isSystemFontUsed": false,
+    "_spacingX": 0,
+    "_isItalic": false,
+    "_isBold": false,
+    "_isUnderline": false,
+    "_underlineHeight": 2,
+    "_cacheMode": 0,
+    "_enableOutline": false,
+    "_outlineColor": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_outlineWidth": 2,
+    "_enableShadow": false,
+    "_shadowColor": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_shadowOffset": {
+      "__type__": "cc.Vec2",
+      "x": 2,
+      "y": 2
+    },
+    "_shadowBlur": 2,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "8d2BkRhZxP9Yg56JmM1/U6"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "76JAcYTsRHhITxu5QafFQ1",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 23
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 100,
+      "height": 100
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "83jg/pzvZBs46uQH/udZSo"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "c46/YsCPVOJYA4mWEpNYRx",
+    "instance": null,
+    "targetOverrides": null
+  }
+]

+ 13 - 0
assets/module_storm_sunder/Prefabs/Blood.prefab.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.50",
+  "importer": "prefab",
+  "imported": true,
+  "uuid": "942a123f-5882-48da-9045-de7ce8febb60",
+  "files": [
+    ".json"
+  ],
+  "subMetas": {},
+  "userData": {
+    "syncNodeName": "Blood"
+  }
+}

+ 1 - 0
assets/module_storm_sunder/Prefabs/Buildings/farm_plot.prefab

@@ -401,6 +401,7 @@
     "__prefab": {
       "__id__": 17
     },
+    "hp": 50,
     "_id": ""
   },
   {

+ 1 - 0
assets/module_storm_sunder/Prefabs/Buildings/house.prefab

@@ -284,6 +284,7 @@
     "__prefab": {
       "__id__": 12
     },
+    "hp": 100,
     "_id": ""
   },
   {

+ 33 - 1
assets/module_storm_sunder/Prefabs/Buildings/lumbermill.prefab

@@ -32,10 +32,13 @@
       },
       {
         "__id__": 11
+      },
+      {
+        "__id__": 13
       }
     ],
     "_prefab": {
-      "__id__": 13
+      "__id__": 15
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -284,12 +287,41 @@
     "__prefab": {
       "__id__": 12
     },
+    "hp": 100,
     "_id": ""
   },
   {
     "__type__": "cc.CompPrefabInfo",
     "fileId": "a1lkQkJ7hK1pxVqoACuuox"
   },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 14
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 100,
+      "height": 100
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "22BMoUJeRA47n5QQylFLxE"
+  },
   {
     "__type__": "cc.PrefabInfo",
     "root": {

+ 1 - 0
assets/module_storm_sunder/Prefabs/Buildings/market.prefab

@@ -284,6 +284,7 @@
     "__prefab": {
       "__id__": 12
     },
+    "hp": 200,
     "_id": ""
   },
   {

+ 1 - 0
assets/module_storm_sunder/Prefabs/Buildings/mill.prefab

@@ -413,6 +413,7 @@
     "__prefab": {
       "__id__": 17
     },
+    "hp": 150,
     "_id": ""
   },
   {

+ 1 - 0
assets/module_storm_sunder/Prefabs/Tornado.prefab

@@ -590,6 +590,7 @@
       "__id__": 0
     },
     "fileId": "7fzeuXamJOA4JobLGguO8T",
+    "instance": null,
     "targetOverrides": null
   }
 ]

+ 25 - 5
assets/module_storm_sunder/Script/Component/PropComponent.ts

@@ -1,18 +1,38 @@
-import { _decorator, Component, Node, tween, Tween, Vec3 } from 'cc';
+import { _decorator, CCFloat, Component, Node, tween, Tween, Vec3 } from 'cc';
 const { ccclass, property } = _decorator;
 
+export enum PropStatus {
+    LIFE,
+    DIE
+}
+
 @ccclass('PropComponent')
 export class PropComponent extends Component {
-    start() {
 
+    @property({ type: CCFloat })
+    hp: number = 1;
+
+    status: PropStatus = PropStatus.LIFE;
+
+    speed: number = 50;
+
+    start() {
+        this.status = PropStatus.LIFE;
     }
 
     //受伤
-    hurt() {
-
+    hurt(attack: number) {
+        if (this.status == PropStatus.DIE) return;
+
+        this.hp -= attack;
+        console.log(`当前道具血量:${this.hp}`)
+        if (this.hp <= 0) {
+            this.hp = 0;
+            this.status = PropStatus.DIE;
+        }
     }
 
-    //食物上升 0.5s消失效果
+    //卷入龙卷风
     swallow() {
         Tween.stopAllByTarget(this.node);
         tween(this.node)

+ 42 - 11
assets/module_storm_sunder/Script/Component/TornadoComponent.ts

@@ -4,9 +4,11 @@ import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDis
 import { GameEvent } from '../Enum/GameEvent';
 import { UIJoyStick } from '../UIJoyStick';
 import { GameMgr, GameStatus } from '../Manager/GameMgr';
-import { PropComponent } from './PropComponent';
+import { PropComponent, PropStatus } from './PropComponent';
 const { ccclass, property } = _decorator;
 
+const rotateSpeed = 500;
+
 /** 龙卷风组件*/
 @ccclass('TornadoComponent')
 export class TornadoComponent extends Component {
@@ -17,10 +19,14 @@ export class TornadoComponent extends Component {
     tigger: Collider = null!; //龙卷风触发器
     radiusTigger: Collider = null!;     //龙卷风半径检测触发器
 
-    attack: number = 1;
+    attack: number = 20;
     speed: number = 50;
+    hp: number = 100;
     ai: boolean = false;
 
+    _attackInterval: number = 0.5; // 攻击间隔
+    _lastAttackTime: Map<string, number> = new Map(); // 记录上次攻击时间
+
     protected start(): void {
         this.initilizeUI();
         this.registerEvent();
@@ -34,21 +40,47 @@ export class TornadoComponent extends Component {
 
         this.tigger.on('onTriggerEnter', this.onTriggerEnter, this);
         this.tigger.on('onTriggerStay', this.onTriggerStay, this);
+        this.tigger.on('onTriggerExit', this.onTriggerExit, this);
     }
 
     onTriggerEnter(event: ITriggerEvent): void {
-        console.log(`龙卷风碰撞到:${event.otherCollider.node.name}`)
-        if (event.otherCollider.getGroup() == 1 << 4) {
-            let comp = event.otherCollider.node.getComponent(PropComponent)!;
 
-            if (comp) {
-                event.otherCollider.node.setParent(this.points[Math.floor(Math.random() * this.points.length)]);
-                event.otherCollider.node.setPosition(Vec3.ZERO);
-                comp.swallow();
+    }
+
+    onTriggerStay(event: ITriggerEvent): void {
+        if (event.otherCollider.getGroup() == 1 << 4) {
+            const otherCollider = event.otherCollider;
+            const propComp = otherCollider.node.getComponent(PropComponent);
+
+            if (!propComp) return;
+
+            const currentTime = game.totalTime;
+            const nodeId = otherCollider.node.uuid;
+            const lastTime = this._lastAttackTime.get(nodeId) || 0;
+
+            // 检查是否达到攻击间隔
+            if (currentTime - lastTime >= this._attackInterval * 1000) {
+                this._lastAttackTime.set(nodeId, currentTime);
+
+                if (propComp.status == PropStatus.DIE) return
+                // 造成伤害
+                propComp.hurt(this.attack);
+
+                // 检查道具是否被摧毁
+                if (propComp.hp <= 0) {
+                    // 随机选择一个吸收点
+                    const randomPoint = this.points[Math.floor(Math.random() * this.points.length)];
+                    if (randomPoint) {
+                        otherCollider.node.parent = randomPoint;
+                        otherCollider.node.setPosition(Vec3.ZERO);
+                        propComp.swallow();
+                    }
+                }
             }
         }
     }
-    onTriggerStay(event: ITriggerEvent): void {
+
+    onTriggerExit(event: ITriggerEvent): void {
 
     }
 
@@ -60,7 +92,6 @@ export class TornadoComponent extends Component {
     }
 
     RotateHandler(): void {
-        const rotateSpeed = 500;
         this.node.eulerAngles = new Vec3(this.node.eulerAngles.x, this.node.eulerAngles.y + rotateSpeed * game.deltaTime, this.node.eulerAngles.z);
         // console.log('this.node.eulerAngles:', this.node.eulerAngles);
     }

+ 1 - 0
assets/start/Start.ts

@@ -18,6 +18,7 @@ const _preloadRes = [
     { bundle: ModuleDef.BASIC, url: 'ui_tips/UI_Tips', type: 'prefab' },
     { bundle: ModuleDef.BASIC, url: 'ui_waiting/UI_Waiting', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/Map', type: 'prefab' },
+    { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/Blood', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/Levels/lvl_1', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Audio/bgm_1.mp3', type: 'audio' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Audio/bgm_2.mp3', type: 'audio' },