181404010226 5 месяцев назад
Родитель
Сommit
c0a822c9d1

+ 6 - 3
assets/Scenes/GameLevel.scene

@@ -115,7 +115,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 360,
-      "y": 667,
+      "y": 667.0000000000001,
       "z": 0
     },
     "_lrot": {
@@ -306,7 +306,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": 0,
+      "y": 1.1368683772161603e-13,
       "z": 0
     },
     "_lrot": {
@@ -20568,6 +20568,9 @@
       "__id__": 533
     },
     "blockMoveCooldown": 1,
+    "refreshButton": {
+      "__id__": 337
+    },
     "_id": "19nrhqXPpAQ7nRPaH27rI/"
   },
   {
@@ -42921,7 +42924,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 720,
-      "height": 1334
+      "height": 1334.0000000000002
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",

+ 20 - 22
assets/resources/data/weapons.json

@@ -183,9 +183,9 @@
         },
         "visual": {
           "bulletPrefab": "bullets/SawBullet",
-          "hitEffect": "Animation/WeaponTx/tx0003/tx0003",
-          "trailEffect": "Animation/WeaponTx/tx0003/tx0003",
-          "muzzleFlash": "Animation/WeaponTx/tx0003/tx0003"
+          "hitEffect": "Animation/WeaponTx/tx0002/tx0002",
+          "trailEffect": "Animation/WeaponTx/tx0002/tx0002",
+          "muzzleFlash": "Animation/WeaponTx/tx0002/tx0002"
         }
       },
       "visualConfig": {
@@ -220,10 +220,9 @@
           "burstDelay": 0
         },
         "trajectory": {
-          "type": "parabolic",
-          "speed": 120,
-          "gravity": 0.8,
-          "arcHeight": 100,
+          "type": "straight",
+          "speed": 20,
+          "gravity": 0,
           "homingStrength": 0,
           "homingDelay": 0
         },
@@ -284,12 +283,11 @@
           "burstDelay": 0
         },
         "trajectory": {
-          "type": "homing_arc",
-          "speed": 150,
-          "gravity": 0.3,
-          "arcHeight": 50,
-          "homingStrength": 0.8,
-          "homingDelay": 0
+          "type": "homing",
+          "speed": 15,
+          "gravity": 0,
+          "homingStrength": 0.5,
+          "homingDelay": 0.3
         },
         "hitEffects": [
           {
@@ -311,9 +309,9 @@
         },
         "visual": {
           "bulletPrefab": "bullets/BoomerangBullet",
-          "hitEffect": "Animation/WeaponTx/tx0004/tx0004",
-          "trailEffect": "Animation/WeaponTx/tx0004/tx0004",
-          "muzzleFlash": "Animation/WeaponTx/tx0004/tx0004"
+          "hitEffect": "Animation/WeaponTx/tx0003/tx0003",
+          "trailEffect": "Animation/WeaponTx/tx0003/tx0003",
+          "muzzleFlash": "Animation/WeaponTx/tx0003/tx0003"
         }
       },
       "visualConfig": {
@@ -450,9 +448,9 @@
         },
         "visual": {
           "bulletPrefab": "bullets/CactusBullet",
-          "hitEffect": "Animation/WeaponTx/tx0008/tx0008",
-          "trailEffect": "Animation/WeaponTx/tx0008/tx0008",
-          "muzzleFlash": "Animation/WeaponTx/tx0008/tx0008"
+          "hitEffect": "Animation/WeaponTx/tx0005/tx0005",
+          "trailEffect": "Animation/WeaponTx/tx0005/tx0005",
+          "muzzleFlash": "Animation/WeaponTx/tx0005/tx0005"
         }
       },
       "visualConfig": {
@@ -487,8 +485,8 @@
           "burstDelay": 0
         },
         "trajectory": {
-          "type": "homing_arc",
-          "speed": 80,
+          "type": "homing",
+          "speed": 20,
           "gravity": 0.2,
           "arcHeight": 100,
           "homingStrength": 0.8,
@@ -539,7 +537,7 @@
   "blockSizes": ["1x1", "1x2", "2x1", "2x2"],
   "bulletEffectTypes": {
     "count": ["single", "spread", "burst"],
-    "trajectory": ["straight", "parabolic", "arc", "homing_arc"],
+    "trajectory": ["straight", "arc", "homing_arc"],
     "hitEffects": ["normal_damage", "pierce_damage", "explosion", "ground_burn", "ricochet_damage"],
     "lifecycle": ["hit_destroy", "range_limit", "ricochet_counter", "ground_impact", "return_trip", "ground_impact_with_effect", "target_impact"]
   }

+ 22 - 1
assets/scripts/CombatSystem/BlockManager.ts

@@ -1,4 +1,4 @@
-import { _decorator, Component, Node, Prefab, instantiate, Vec3, EventTouch, Vec2, UITransform, find, Rect, Label, Color, Size, Sprite, SpriteFrame, resources } from 'cc';
+import { _decorator, Component, Node, Prefab, instantiate, Vec3, EventTouch, Vec2, UITransform, find, Rect, Label, Color, Size, Sprite, SpriteFrame, resources, Button } from 'cc';
 import { ConfigManager, WeaponConfig } from '../Core/ConfigManager';
 const { ccclass, property } = _decorator;
 
@@ -89,6 +89,13 @@ export class BlockManager extends Component {
     // 方块武器配置映射
     private blockWeaponConfigs: Map<Node, WeaponConfig> = new Map();
     
+    // 刷新方块按钮节点(ann003)
+    @property({
+        type: Node,
+        tooltip: '拖拽BlockSelectionUI/diban/ann003按钮节点到这里'
+    })
+    public refreshButton: Node = null;
+    
     // 检查方块是否可以移动(冷却检查)
     private canMoveBlock(block: Node): boolean {
         if (!this.gameStarted) {
@@ -181,6 +188,15 @@ export class BlockManager extends Component {
         // 初始化网格占用情况
         this.initGridOccupationMap();
         
+        if (this.refreshButton) {
+            const btn = this.refreshButton.getComponent(Button);
+            if (btn) {
+                this.refreshButton.on(Button.EventType.CLICK, this.onRefreshButtonClicked, this);
+            } else {
+                // 兼容没有 Button 组件的情况
+                this.refreshButton.on(Node.EventType.TOUCH_END, this.onRefreshButtonClicked, this);
+            }
+        }
         // 等待配置加载完成后生成方块
         this.scheduleOnce(() => {
             this.generateRandomBlocksInKuang();
@@ -1156,4 +1172,9 @@ export class BlockManager extends Component {
         console.log('刷新方块,生成新的武器方块');
         this.generateRandomBlocksInKuang();
     }
+
+    // 刷新按钮点击回调
+    private onRefreshButtonClicked() {
+        this.refreshBlocks();
+    }
 }

+ 17 - 36
assets/scripts/CombatSystem/BulletEffects/BulletTrajectory.ts

@@ -7,12 +7,11 @@ const { ccclass, property } = _decorator;
  */
 
 export interface BulletTrajectoryConfig {
-    type: 'straight' | 'parabolic' | 'arc' | 'homing_arc';  // 弹道类型
-    speed: number;                                          // 初始速度
-    gravity: number;                                        // 重力影响
-    arcHeight: number;                                      // 弧线高度
-    homingStrength: number;                                 // 追踪强度 (0-1)
-    homingDelay: number;                                    // 追踪延迟(秒)
+    type: 'straight' | 'parabolic' | 'homing';  // 弹道类型
+    speed: number;                              // 初始速度
+    gravity: number;                            // 重力影响
+    homingStrength: number;                     // 追踪强度 (0-1)
+    homingDelay: number;                        // 追踪延迟(秒)
 }
 
 export interface TrajectoryState {
@@ -59,7 +58,7 @@ export class BulletTrajectory extends Component {
         this.applyInitialVelocity();
         
         // 寻找目标(用于追踪弹道)
-        if (config.type === 'homing_arc') {
+        if (config.type === 'homing') {
             this.findTarget();
         }
         
@@ -79,13 +78,18 @@ export class BulletTrajectory extends Component {
                 break;
                 
             case 'parabolic':
-            case 'arc':
-            case 'homing_arc':
                 // 计算抛物线初始速度
                 const velocity = this.calculateParabolicVelocity();
                 this.rigidBody.linearVelocity = velocity;
                 this.state.currentVelocity.set(velocity.x, velocity.y, 0);
                 break;
+                
+            case 'homing':
+                this.rigidBody.linearVelocity = new Vec2(
+                    this.state.initialVelocity.x,
+                    this.state.initialVelocity.y
+                );
+                break;
         }
     }
     
@@ -95,8 +99,8 @@ export class BulletTrajectory extends Component {
     private calculateParabolicVelocity(): Vec2 {
         // NOTE:
         // 1. 当目标位于子弹正上/下方时, 原 direction 的 x 分量可能非常小甚至为 0, 导致 vx≈0, 子弹会几乎垂直运动, 看起来像"钢球"直落。
-        // 2. 对于抛物线/弧线弹道, 我们总是希望子弹具备一个最小的水平速度, 并且保证初速度向上( vy>0 ),
-        //    这样才能形成明显的抛物或弧线效果并最终击中目标。
+        // 2. 对于抛物线弹道, 我们总是希望子弹具备一个最小的水平速度, 并且保证初速度向上( vy>0 ),
+        //    这样才能形成明显的抛物线效果并最终击中目标。
 
         const rawDir = this.state.initialVelocity.clone().normalize();
 
@@ -117,7 +121,7 @@ export class BulletTrajectory extends Component {
         // 计算纵向初速度, 使得理论最高点接近 arcHeight
         // vy = sqrt(2 * g * h)
         const g = Math.max(0.1, Math.abs(this.config.gravity * 9.8)); // 避免 g=0 导致除0或 vy=0
-        const desiredHeight = Math.max(1, this.config.arcHeight); // 至少 1 避免 0 导致 vy=0
+        const desiredHeight = Math.max(1, 20); // 使用固定高度20作为默认抛物线高度
         let vy = Math.sqrt(2 * g * desiredHeight);
 
         // 如果原始方向有明显的向上分量, 为了兼容旧配置, 适当叠加
@@ -183,10 +187,7 @@ export class BulletTrajectory extends Component {
             case 'parabolic':
                 this.updateParabolicTrajectory(dt);
                 break;
-            case 'arc':
-                this.updateArcTrajectory(dt);
-                break;
-            case 'homing_arc':
+            case 'homing':
                 this.updateHomingTrajectory(dt);
                 break;
         }
@@ -224,29 +225,10 @@ export class BulletTrajectory extends Component {
         this.state.currentVelocity.set(currentVel.x, currentVel.y - gravityForce, 0);
     }
     
-    /**
-     * 更新弧线弹道
-     */
-    private updateArcTrajectory(dt: number) {
-        // 先应用基础的抛物线逻辑 (受重力影响)
-        this.updateParabolicTrajectory(dt);
-
-        // 再在垂直方向叠加一个小幅度的正弦扰动, 让轨迹更加圆润。
-        const t = this.state.elapsedTime;
-        const sinus = Math.sin(t * Math.PI); // [-1,1]
-        const extraVy = sinus * this.config.arcHeight * 0.05; // 0.05 系数保证不至于过大
-
-        const curVel = this.rigidBody.linearVelocity;
-        this.rigidBody.linearVelocity = new Vec2(curVel.x, curVel.y + extraVy);
-    }
-    
     /**
      * 更新追踪弹道
      */
     private updateHomingTrajectory(dt: number) {
-        // 先按抛物线运动
-        this.updateParabolicTrajectory(dt);
-
         // 追踪延迟后开始追踪
         if (this.homingTimer > 0) {
             this.homingTimer -= dt;
@@ -362,7 +344,6 @@ export class BulletTrajectory extends Component {
         
         if (config.speed <= 0) return false;
         if (config.gravity < 0) return false;
-        if (config.arcHeight < 0) return false;
         if (config.homingStrength < 0 || config.homingStrength > 1) return false;
         if (config.homingDelay < 0) return false;
         

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

@@ -45,7 +45,7 @@ export interface WeaponConfig {
 export interface BulletInitData {
     weaponId: string;           // 武器ID,用于查找配置
     firePosition: Vec3;         // 发射位置
-    direction?: Vec3;           // 发射方向(可选,自动瞄准时会自动计算
+    direction?: Vec3;           // 发射方向(可选)
     autoTarget?: boolean;       // 是否自动瞄准
     weaponConfig?: WeaponConfig; // 直接传入的武器配置(优先级更高)
 }
@@ -209,16 +209,20 @@ export class WeaponBullet extends Component {
         // 初始化弹道组件
         this.bulletTrajectory = this.getComponent(BulletTrajectory) || this.addComponent(BulletTrajectory);
         const trajCfg: BulletTrajectoryConfig = { ...config.trajectory, speed: this.weaponConfig.stats.bulletSpeed };
+        
+        // 计算方向
+        const direction = initData.direction || this.calculateDirection(initData.autoTarget);
+        
         this.bulletTrajectory.init(
             trajCfg,
-            initData.direction || this.calculateDirection(initData.autoTarget),
+            direction,
             initData.firePosition
         );
         
         // --- 额外偏移 ---
         // 若子弹在生成时与发射方块碰撞(位置重叠), 会立刻触发碰撞事件导致被销毁。
         // 因此在初始化完弹道后, 将子弹沿发射方向平移一小段距离(默认 30 像素左右)。
-        const dir = (initData.direction || this.calculateDirection(initData.autoTarget)).clone().normalize();
+        const dir = direction.clone().normalize();
         const spawnOffset = 30; // 可根据子弹半径或方块大小调整
         if (!Number.isNaN(dir.x) && !Number.isNaN(dir.y)) {
             const newLocalPos = this.node.position.clone().add(new Vec3(dir.x * spawnOffset, dir.y * spawnOffset, 0));