Browse Source

武器旋转优化

181404010226 2 months ago
parent
commit
4399e49850

+ 77 - 77
assets/assets/Prefabs/PelletContainer.prefab

@@ -80,14 +80,14 @@
   },
   {
     "__type__": "cc.Node",
-    "_name": "Pellet",
+    "_name": "TrailEffect",
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
       "__id__": 1
     },
     "_children": [],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 3
@@ -142,8 +142,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 57,
-      "height": 57
+      "width": 100,
+      "height": 100
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -154,10 +154,10 @@
   },
   {
     "__type__": "cc.CompPrefabInfo",
-    "fileId": "4cFfiGSRRNBJ6HQnvWhKN6"
+    "fileId": "TrailEffectUITransform001"
   },
   {
-    "__type__": "cc.Sprite",
+    "__type__": "cc.MotionStreak",
     "_name": "",
     "_objFlags": 0,
     "__editorExtras__": {},
@@ -178,25 +178,20 @@
       "b": 255,
       "a": 255
     },
-    "_spriteFrame": null,
-    "_type": 0,
-    "_fillType": 0,
-    "_sizeMode": 1,
-    "_fillCenter": {
-      "__type__": "cc.Vec2",
-      "x": 0,
-      "y": 0
+    "_preview": false,
+    "_fadeTime": 0.5,
+    "_minSeg": 1.1,
+    "_stroke": 30,
+    "_texture": {
+      "__uuid__": "87ea3ba6-4cd5-4189-8d1d-9d069ea009a8@6c48a",
+      "__expectedType__": "cc.Texture2D"
     },
-    "_fillStart": 0,
-    "_fillRange": 0,
-    "_isTrimmedMode": true,
-    "_useGrayscale": false,
-    "_atlas": null,
+    "_fastMode": false,
     "_id": ""
   },
   {
     "__type__": "cc.CompPrefabInfo",
-    "fileId": "5eXYZPbTFA2p6UgLI/X6fq"
+    "fileId": "TrailEffectMotionStreak001"
   },
   {
     "__type__": "cc.PrefabInfo",
@@ -206,21 +201,21 @@
     "asset": {
       "__id__": 0
     },
-    "fileId": "b1luMUWcFJmqi7I1A/cZXE",
+    "fileId": "TrailEffectPrefabInfo001",
     "instance": null,
     "targetOverrides": null,
     "nestedPrefabInstanceRoots": null
   },
   {
     "__type__": "cc.Node",
-    "_name": "TrailEffect",
+    "_name": "Spine",
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
       "__id__": 1
     },
     "_children": [],
-    "_active": false,
+    "_active": true,
     "_components": [
       {
         "__id__": 9
@@ -234,16 +229,16 @@
     },
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 0,
-      "y": 0,
+      "x": -92.176,
+      "y": -5.938,
       "z": 0
     },
     "_lrot": {
       "__type__": "cc.Quat",
       "x": 0,
       "y": 0,
-      "z": 0,
-      "w": 1
+      "z": 0.7071067811865476,
+      "w": -0.7071067811865475
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -252,12 +247,12 @@
       "z": 1
     },
     "_mobility": 0,
-    "_layer": 33554432,
+    "_layer": 1073741824,
     "_euler": {
       "__type__": "cc.Vec3",
       "x": 0,
       "y": 0,
-      "z": 0
+      "z": 270
     },
     "_id": ""
   },
@@ -275,22 +270,22 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 100,
-      "height": 100
+      "width": 72.06999969482422,
+      "height": 175.0399932861328
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
-      "x": 0.5,
-      "y": 0.5
+      "x": 0.630914408397987,
+      "y": 0.5104547640610523
     },
     "_id": ""
   },
   {
     "__type__": "cc.CompPrefabInfo",
-    "fileId": "TrailEffectUITransform001"
+    "fileId": "56KO0APYtKRrRSDUqPjZT4"
   },
   {
-    "__type__": "cc.MotionStreak",
+    "__type__": "sp.Skeleton",
     "_name": "",
     "_objFlags": 0,
     "__editorExtras__": {},
@@ -311,20 +306,28 @@
       "b": 255,
       "a": 255
     },
-    "_preview": false,
-    "_fadeTime": 0.5,
-    "_minSeg": 1.1,
-    "_stroke": 30,
-    "_texture": {
-      "__uuid__": "87ea3ba6-4cd5-4189-8d1d-9d069ea009a8@6c48a",
-      "__expectedType__": "cc.Texture2D"
+    "_skeletonData": {
+      "__uuid__": "15209fa2-9c09-477e-a266-1bd7596cc915",
+      "__expectedType__": "sp.SkeletonData"
     },
-    "_fastMode": false,
+    "defaultSkin": "default",
+    "defaultAnimation": "",
+    "_premultipliedAlpha": true,
+    "_timeScale": 1,
+    "_preCacheMode": 0,
+    "_cacheMode": 0,
+    "_sockets": [],
+    "_useTint": false,
+    "_debugMesh": false,
+    "_debugBones": false,
+    "_debugSlots": false,
+    "_enableBatch": false,
+    "loop": true,
     "_id": ""
   },
   {
     "__type__": "cc.CompPrefabInfo",
-    "fileId": "TrailEffectMotionStreak001"
+    "fileId": "2buPpbG2ZO06BJlQOG5/cL"
   },
   {
     "__type__": "cc.PrefabInfo",
@@ -334,14 +337,14 @@
     "asset": {
       "__id__": 0
     },
-    "fileId": "TrailEffectPrefabInfo001",
+    "fileId": "e4cE95pldB5qMiM5U9zRCY",
     "instance": null,
     "targetOverrides": null,
     "nestedPrefabInstanceRoots": null
   },
   {
     "__type__": "cc.Node",
-    "_name": "Spine",
+    "_name": "Pellet",
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
@@ -362,16 +365,16 @@
     },
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": -92.176,
-      "y": -5.938,
+      "x": 0,
+      "y": 0,
       "z": 0
     },
     "_lrot": {
       "__type__": "cc.Quat",
       "x": 0,
       "y": 0,
-      "z": 0.7071067811865476,
-      "w": -0.7071067811865475
+      "z": 0,
+      "w": 1
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -380,12 +383,12 @@
       "z": 1
     },
     "_mobility": 0,
-    "_layer": 1073741824,
+    "_layer": 33554432,
     "_euler": {
       "__type__": "cc.Vec3",
       "x": 0,
       "y": 0,
-      "z": 270
+      "z": 0
     },
     "_id": ""
   },
@@ -403,22 +406,22 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 72.06999969482422,
-      "height": 175.0399932861328
+      "width": 57,
+      "height": 57
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
-      "x": 0.630914408397987,
-      "y": 0.5104547640610523
+      "x": 0.5,
+      "y": 0.5
     },
     "_id": ""
   },
   {
     "__type__": "cc.CompPrefabInfo",
-    "fileId": "56KO0APYtKRrRSDUqPjZT4"
+    "fileId": "4cFfiGSRRNBJ6HQnvWhKN6"
   },
   {
-    "__type__": "sp.Skeleton",
+    "__type__": "cc.Sprite",
     "_name": "",
     "_objFlags": 0,
     "__editorExtras__": {},
@@ -439,28 +442,25 @@
       "b": 255,
       "a": 255
     },
-    "_skeletonData": {
-      "__uuid__": "15209fa2-9c09-477e-a266-1bd7596cc915",
-      "__expectedType__": "sp.SkeletonData"
+    "_spriteFrame": null,
+    "_type": 0,
+    "_fillType": 0,
+    "_sizeMode": 1,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
     },
-    "defaultSkin": "default",
-    "defaultAnimation": "",
-    "_premultipliedAlpha": true,
-    "_timeScale": 1,
-    "_preCacheMode": 0,
-    "_cacheMode": 0,
-    "_sockets": [],
-    "_useTint": false,
-    "_debugMesh": false,
-    "_debugBones": false,
-    "_debugSlots": false,
-    "_enableBatch": false,
-    "loop": true,
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_useGrayscale": false,
+    "_atlas": null,
     "_id": ""
   },
   {
     "__type__": "cc.CompPrefabInfo",
-    "fileId": "2buPpbG2ZO06BJlQOG5/cL"
+    "fileId": "5eXYZPbTFA2p6UgLI/X6fq"
   },
   {
     "__type__": "cc.PrefabInfo",
@@ -470,7 +470,7 @@
     "asset": {
       "__id__": 0
     },
-    "fileId": "e4cE95pldB5qMiM5U9zRCY",
+    "fileId": "b1luMUWcFJmqi7I1A/cZXE",
     "instance": null,
     "targetOverrides": null,
     "nestedPrefabInstanceRoots": null
@@ -584,7 +584,7 @@
       "__id__": 27
     },
     "motionStreak": {
-      "__id__": 11
+      "__id__": 5
     },
     "_id": ""
   },

+ 15 - 11
assets/data/weapons.json

@@ -159,7 +159,8 @@
           "bulletImages": "images/PlantsSprite/002",
           "hitEffect": "Animation/WeaponTx/tx0002/tx0002",
           "trailEffect": "Animation/WeaponTx/tx0001/tx0001"
-        }
+        },
+        "shouldRotate": false
       },
       "visualConfig": {
         "weaponSprites": "images/PlantsSprite/002",
@@ -627,7 +628,8 @@
           "hitEffect": "Animation/WeaponTx/tx0002/tx0002",
           "trailEffect": true,
           "burnEffect": "Animation/WeaponBurnAni/燃烧/ui_zhuling"
-        }
+        },
+        "shouldRotate": false
       },
       "visualConfig": {
         "weaponSprites": "images/PlantsSprite/005",
@@ -827,12 +829,12 @@
           "burstDelay": 0
         },
         "trajectory": {
-          "type": "homing",
-          "speed": 20,
-          "gravity": 0.2,
-          "arcHeight": 100,
-          "homingStrength": 0.8,
-          "homingDelay": 0.3
+          "type": "arc",
+          "speed": 200,
+          "gravity": 0,
+          "arcHeight": 0,
+          "homingStrength": 0,
+          "homingDelay": 0
         },
         "hitEffects": [
           {
@@ -844,7 +846,7 @@
           }
         ],
         "lifecycle": {
-          "type": "target_impact",
+          "type": "ground_impact",
           "maxLifetime": 5.0,
           "penetration": 1,
           "ricochetCount": 0,
@@ -855,7 +857,8 @@
           "hitEffect": "Animation/WeaponTx/tx0002/tx0002",
           "trailEffect": true,
           "explosionEffect": "Animation/WeaponTx/tx0007/tx0007"
-        }
+        },
+        "shouldRotate": false
       },
       "visualConfig": {
         "weaponSprites": "images/PlantsSprite/006",
@@ -973,7 +976,8 @@
           "bulletImages": "images/PlantsSprite/009",
           "hitEffect": "Animation/WeaponTx/tx0002/tx0002",
           "trailEffect": true
-        }
+        },
+        "shouldRotate": false
       },
       "visualConfig": {
         "weaponSprites": "images/PlantsSprite/009",

+ 0 - 9
assets/resources/prefabs/Shop.meta

@@ -1,9 +0,0 @@
-{
-  "ver": "1.2.0",
-  "importer": "directory",
-  "imported": true,
-  "uuid": "b704c0a6-3fd0-4cc5-84c0-788f6f061b31",
-  "files": [],
-  "subMetas": {},
-  "userData": {}
-}

+ 0 - 18
assets/scripts/CombatSystem/BulletEffects/BulletLifecycle.ts

@@ -72,9 +72,6 @@ export class BulletLifecycle extends Component {
             case 'return_trip':
                 return this.handleReturnTrip();
                 
-            case 'target_impact':
-                return this.handleTargetImpact(hitNode);
-                
             default:
                 return true; // 默认销毁
         }
@@ -178,21 +175,6 @@ export class BulletLifecycle extends Component {
         return false;
     }
     
-    /**
-     * 处理目标撞击逻辑(导弹)
-     */
-    private handleTargetImpact(hitNode: Node): boolean {
-        const isEnemy = this.isEnemyNode(hitNode);
-        
-        if (isEnemy) {
-            this.state.shouldDestroy = true;
-            return true;
-        }
-        
-        // 如果不是敌人,继续飞行(导弹不会被其他物体阻挡)
-        return false;
-    }
-    
     /**
      * 判断是否为地面节点
      */

+ 13 - 3
assets/scripts/CombatSystem/WeaponBullet.ts

@@ -293,9 +293,6 @@ export class WeaponBullet extends Component {
         // 确保物理组件存在
         this.setupPhysics();
         
-        // 设置物理角速度,实现持续旋转
-        this.applyAutoRotation();
-        
         // 初始化弹道组件
         this.bulletTrajectory = this.getComponent(BulletTrajectory) || this.addComponent(BulletTrajectory);
         const trajCfg: BulletTrajectoryConfig = { ...config.trajectory, speed: this.weaponConfig.stats.bulletSpeed };
@@ -310,6 +307,19 @@ export class WeaponBullet extends Component {
             this.node.angle = deg;
         }
         
+        // 根据配置决定旋转行为
+        if (config.shouldRotate !== false) { 
+            // 默认为true,启用持续自旋转
+            this.applyAutoRotation();
+        } else {
+            // shouldRotate为false时,让Pellet子节点根据发射方向旋转
+            const pelletNode = this.node.getChildByName('Pellet');
+            if (pelletNode && direction) {
+                const deg = math.toDegree(Math.atan2(direction.y, direction.x));
+                pelletNode.angle = deg;
+            }
+        }
+        
         this.bulletTrajectory.init(
             trajCfg,
             direction,

+ 1 - 0
assets/scripts/Core/ConfigManager.ts

@@ -82,6 +82,7 @@ export interface WeaponConfig {
             trailEffect?: string;
             explosionEffect?: string;
         };
+        shouldRotate?: boolean; // 是否旋转,默认为true
     };
     visualConfig: {
         weaponSprites: {