181404010226 5 kuukautta sitten
vanhempi
commit
3542a2408a

+ 1 - 2
assets/resources/data/weapons.json

@@ -307,8 +307,7 @@
           "penetration": 999,
           "ricochetCount": 0,
           "returnToOrigin": true,
-          "returnDelay": 1.0,
-          "maxRange": 300
+          "returnDelay": 1.0
         },
         "visual": {
           "bulletPrefab": "bullets/BoomerangBullet",

+ 24 - 19
assets/scripts/CombatSystem/BulletEffects/BulletLifecycle.ts

@@ -176,19 +176,15 @@ export class BulletLifecycle extends Component {
      */
     private handleReturnTrip(): boolean {
         if (this.state.phase === 'active') {
-            // 穿透命中,继续飞行
-            if (this.state.pierceLeft > 0) {
-                this.state.pierceLeft--;
-                console.log(`🪃 回旋镖穿透命中, 剩余穿透: ${this.state.pierceLeft}`);
-                return false;
-            }
+            // 首次命中立即开始返程,不再依据pierceLeft
+            console.log('🪃 回旋镖命中敌人,开始返回');
+            this.startReturn();
+            return false; // 不销毁
         } else if (this.state.phase === 'returning') {
-            // 返回途中命中,继续返回
-            console.log('🪃 回旋镖返回途中命中');
+            // 返回途中命中,仅造成伤害不销毁
             return false;
         }
-        
-        return false; // 回旋镖不会因为命中而销毁
+        return false;
     }
     
     /**
@@ -269,23 +265,32 @@ export class BulletLifecycle extends Component {
             return;
         }
         
-        // 检查射程限制
+        // === 射程限制逻辑优化 ===
         if (this.config.maxRange && this.state.travelDistance >= this.config.maxRange) {
-            console.log(`📏 子弹超出射程限制: ${this.state.travelDistance}/${this.config.maxRange}`);
-            
-            if (this.config.type === 'return_trip' && this.state.phase === 'active') {
-                // 回旋镖到达最远距离,开始返回
-                this.startReturn();
-            } else {
+            if (this.config.type === 'range_limit') {
+                // 仅当生命周期类型专门设为 range_limit 时才销毁
+                console.log(`📏 子弹超出射程限制: ${this.state.travelDistance}/${this.config.maxRange}`);
                 this.state.shouldDestroy = true;
+            } else if (this.config.type === 'return_trip') {
+                // 回旋镖:首次超距时开始返回;返回途中不再因射程销毁
+                if (this.state.phase === 'active') {
+                    console.log(`📏 回旋镖到达最远距离(${this.config.maxRange}),开始返回`);
+                    this.startReturn();
+                }
             }
+            // 其他生命周期类型忽略射程限制
             return;
         }
         
         // 检查越界
         if (this.checkOutOfBounds()) {
-            console.log('🌍 子弹飞出游戏区域');
-            this.state.shouldDestroy = true;
+            if (this.config.type === 'return_trip' && this.state.phase === 'active') {
+                console.log('🌍 回旋镖飞到屏幕边界,开始返回');
+                this.startReturn();
+            } else {
+                console.log('🌍 子弹飞出游戏区域');
+                this.state.shouldDestroy = true;
+            }
             return;
         }
     }

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

@@ -289,8 +289,9 @@ export class WeaponBullet extends Component {
             return direction;
         }
         
-        // 默认向右
-        return new Vec3(1, 0, 0);
+        // 若没有敌人则随机方向发射
+        const angle = Math.random() * Math.PI * 2;
+        return new Vec3(Math.cos(angle), Math.sin(angle), 0);
     }
     
     /**