Kaynağa Gözat

多重射击解决

181404010226 3 ay önce
ebeveyn
işleme
68e17bc9d0

+ 1 - 1
assets/resources/data/ballController.json

@@ -1,5 +1,5 @@
 {
-  "baseSpeed": 12.0,
+  "baseSpeed": 39.0,
   "maxReflectionRandomness": 0.2,
   "antiTrapTimeWindow": 5,
   "antiTrapHitThreshold": 5,

+ 5 - 7
assets/scripts/Animations/BallAni.ts

@@ -119,8 +119,6 @@ export class BallAni extends Component {
         
         const weaponNode = prefabRoot.getChildByName('Weapon');
         
-
-        
         // 保存原始材质和缩放
         // 优先保存customMaterial,如果没有则保存当前material
         const originalMaterial = sprite ? (sprite.customMaterial || sprite.material) : null;
@@ -130,7 +128,7 @@ export class BallAni extends Component {
         
         if (hasActiveEnemies) {
             // 有敌人时播放方块缩放动画(包括Node和Weapon子节点)
-            const shrinkBlockScale = new Vec3(0.7, 0.7, 1);
+            const shrinkBlockScale = new Vec3(0.8, 0.8, 1);
             
             // 应用白色描边材质到Node子节点的Sprite组件
             if (sprite && BallAni.whiteMaterial) {
@@ -140,18 +138,18 @@ export class BallAni extends Component {
             // 对方块预制体进行缩放动画
             // Weapon节点需要在其原有0.4倍基础上再进行缩放动画
             const weaponShrinkScale = originalWeaponScale ? new Vec3(
-                originalWeaponScale.x * 0.7, // 在0.4倍基础上再缩小到0.7
-                originalWeaponScale.y * 0.7,
+                originalWeaponScale.x * 0.8, // 在0.4倍基础上再缩小到0.8
+                originalWeaponScale.y * 0.8,
                 originalWeaponScale.z
             ) : null;
             
             const animationTween = tween(blockNode)
-                .to(0.2, { scale: shrinkBlockScale }, {
+                .to(0.1, { scale: shrinkBlockScale }, {
                     onStart: () => {
                         // 开始动画时,同时缩放Weapon节点
                         if (weaponNode && weaponShrinkScale) {
                             tween(weaponNode)
-                                .to(0.2, { scale: weaponShrinkScale })
+                                .to(0.1, { scale: weaponShrinkScale })
                                 .start();
                         }
                     }

+ 9 - 6
assets/scripts/CombatSystem/BulletEffects/BulletCount.ts

@@ -287,15 +287,19 @@ export class BulletCount extends Component {
         }
         // 获取多重射击技能等级
         const multiShotSkillLevel = skillManager.getSkillLevel('multi_shots');
+        console.log(`[BulletCount] 多重射击技能等级: ${multiShotSkillLevel}`);
         if (multiShotSkillLevel <= 0) {
+            console.log(`[BulletCount] 技能等级为0,返回原配置`);
             return originalConfig; // 技能等级为0,返回原配置
         }
         const bulletCountConfig = originalConfig.bulletConfig.count;
         // 计算多重射击几率
         const baseMultiShotChance = 0; // 基础几率为0
         const multiShotChance = SkillManager.calculateMultiShotChance(baseMultiShotChance, multiShotSkillLevel);
+        console.log(`[BulletCount] 多重射击几率: ${multiShotChance}`);
         // 检查是否触发多重射击
         const shouldTriggerMultiShot = SkillManager.rollMultiShot(multiShotChance);
+        console.log(`[BulletCount] 是否触发多重射击: ${shouldTriggerMultiShot}`);
         if (!shouldTriggerMultiShot) {
             return originalConfig; // 未触发多重射击,返回原配置
         }
@@ -304,13 +308,12 @@ export class BulletCount extends Component {
         const multiShotBulletCount = SkillManager.calculateMultiShotBulletCount(baseBulletCount, multiShotSkillLevel);
         // 创建修改后的配置
         const modifiedConfig: any = JSON.parse(JSON.stringify(originalConfig)); // 深拷贝
-        // 修改子弹配置为散射模式
+        // 修改子弹配置为连射模式(同一方向连续发射)
         modifiedConfig.bulletConfig.count = {
-            type: 'spread',
-            amount: multiShotBulletCount,
-            spreadAngle: 30, // 30度散射角度,可以根据需要调整
-            burstCount: bulletCountConfig.burstCount || 1,
-            burstDelay: bulletCountConfig.burstDelay || 0
+            type: 'burst',
+            amount: 2, // 每次连射发射1发子弹
+            burstCount: multiShotBulletCount, // 连射次数
+            burstDelay: 50 // 连射间隔50毫秒,可以根据需要调整
         };
         console.log(`多重射击触发!技能等级: ${multiShotSkillLevel}, 子弹数量: ${multiShotBulletCount}`);
         return modifiedConfig;

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

@@ -127,13 +127,9 @@ export class Wall extends Component {
      * 从存档加载墙体血量
      */
     private loadWallHealthFromSave() {
-        const pd = this.saveDataManager.getPlayerData();
-        if (pd && typeof pd.wallBaseHealth === 'number') {
-            this.currentHealth = pd.wallBaseHealth;
-        } else {
-            // 如果没有存档数据,使用默认血量
-            this.currentHealth = this.getWallHealthByLevel(1);
-        }
+        // 直接从SaveDataManager获取当前墙体血量
+        this.currentHealth = this.saveDataManager.getWallHealth();
+        console.log('[Wall] 从配置加载墙体血量:', this.currentHealth);
         
         // 确保当前血量不超过最大血量(考虑技能加成)
         const maxHealth = this.getMaxHealth();

+ 20 - 6
assets/scripts/CombatSystem/WeaponBullet.ts

@@ -170,7 +170,6 @@ export class WeaponBullet extends Component {
             const createBullet = () => {
                 try {
                     const bullet = instantiate(bulletPrefab);
-                    console.log(`[WeaponBullet] 子弹实例化成功 - 节点: ${bullet ? bullet.name : 'null'}, 是否有效: ${bullet ? bullet.isValid : 'false'}`);
                     
                     const weaponBullet = bullet.getComponent(WeaponBullet) || bullet.addComponent(WeaponBullet);
                     
@@ -182,18 +181,33 @@ export class WeaponBullet extends Component {
                         weaponConfig: config
                     });
                     
-                    bullets.push(bullet);
+                    return bullet;
                 } catch (error) {
                     console.error(`[WeaponBullet] 子弹创建失败:`, error);
+                    return null;
                 }
             };
             
-            // 处理延迟发射
+            // 处理延迟发射 - 对于burst模式,所有子弹都应该被创建并返回
             if (spawnInfo.delay > 0) {
-                // 这里需要一个全局的调度器来处理延迟,暂时直接创建
-                setTimeout(createBullet, spawnInfo.delay * 1000);
+                // 延迟发射:先创建子弹,然后延迟激活
+                const bullet = createBullet();
+                if (bullet) {
+                    // 先禁用子弹,延迟后再激活
+                    bullet.active = false;
+                    bullets.push(bullet);
+                    setTimeout(() => {
+                        if (bullet && bullet.isValid) {
+                            bullet.active = true;
+                            //console.log(`[WeaponBullet] 延迟子弹激活 - 延迟: ${spawnInfo.delay}ms`);
+                        }
+                    }, spawnInfo.delay);
+                }
             } else {
-                createBullet();
+                const bullet = createBullet();
+                if (bullet) {
+                    bullets.push(bullet);
+                }
             }
         }
         

+ 11 - 5
assets/scripts/LevelSystem/SaveDataManager.ts

@@ -35,7 +35,6 @@ export interface PlayerData {
 
     // 墙体等级系统
     wallLevel: number;       // 墙体等级
-    wallBaseHealth: number;  // 墙体基础血量
     
     // 关卡进度
     currentLevel: number;
@@ -273,11 +272,10 @@ export class SaveDataManager {
             lastPlayTime: Date.now(),
             totalPlayTime: 0,
             
-            money: 1000,        // 初始局外金币
-            diamonds: 20,      // 初始钻石
+            money: 0,        // 初始局外金币
+            diamonds: 0,      // 初始钻石
             
             wallLevel: 1,       // 初始墙体等级
-            wallBaseHealth: 100, // 初始墙体基础血量
             
             currentLevel: 1,
             maxUnlockedLevel: 1,
@@ -360,7 +358,6 @@ export class SaveDataManager {
             money: 0,           // 初始局外金钱
             diamonds: 20,
             wallLevel: 1,        // 初始墙体等级
-            wallBaseHealth: 100, // 初始墙体基础血量
             currentLevel: 1,
             maxUnlockedLevel: 1,
             levelProgress: {},
@@ -464,6 +461,15 @@ export class SaveDataManager {
     public getWallLevel(): number {
         return this.playerData?.wallLevel || 1;
     }
+
+    public getWallHealth(): number {
+        const wallLevel = this.getWallLevel();
+        if (this.wallConfig && this.wallConfig.wallConfig && this.wallConfig.wallConfig.healthByLevel) {
+            return this.wallConfig.wallConfig.healthByLevel[wallLevel.toString()] || 200;
+        }
+        // 如果没有配置,返回默认值
+        return 200;
+    }
     
     public getCurrentLevel(): number {
         return this.playerData?.currentLevel || 1;