181404010226 3 сар өмнө
parent
commit
1053a38a94

BIN
assets/resources/data/excel/__pycache__/generate_excel_from_json.cpython-313.pyc


+ 12 - 0
assets/resources/data/excel/__pycache__/generate_excel_from_json.cpython-313.pyc.meta

@@ -0,0 +1,12 @@
+{
+  "ver": "1.0.0",
+  "importer": "*",
+  "imported": true,
+  "uuid": "17256dec-0c99-454f-b179-ce2d8becaa2a",
+  "files": [
+    ".json",
+    ".pyc"
+  ],
+  "subMetas": {},
+  "userData": {}
+}

BIN
assets/resources/data/excel/__pycache__/weapon_config_manager.cpython-313.pyc


+ 35 - 7
assets/resources/data/excel/weapon_config_manager.py

@@ -361,11 +361,16 @@ class WeaponConfigManager:
                             
                             # 读取各形状成本
                             shape_fields = {
-                                'I': ['I形状', 'I_shape', 'I'],
-                                'H-I': ['H-I形状', 'HI_shape', 'H-I'],
-                                'L': ['L形状', 'L_shape', 'L'],
-                                'S': ['S形状', 'S_shape', 'S'],
-                                'D-T': ['D-T形状', 'DT_shape', 'D-T']
+                                'I': ['I形状成本', 'I形状', 'I_shape', 'I'],
+                                'H-I': ['H-I形状成本', 'H-I形状', 'HI_shape', 'H-I'],
+                                'L': ['L形状成本', 'L形状', 'L_shape', 'L'],
+                                'S': ['S形状成本', 'S形状', 'S_shape', 'S'],
+                                'D-T': ['D-T形状成本', 'D-T形状', 'DT_shape', 'D-T'],
+                                'L2': ['L2形状成本', 'L2形状', 'L2_shape', 'L2'],
+                                'L3': ['L3形状成本', 'L3形状', 'L3_shape', 'L3'],
+                                'L4': ['L4形状成本', 'L4形状', 'L4_shape', 'L4'],
+                                'F-S': ['F-S形状成本', 'F-S形状', 'FS_shape', 'F-S'],
+                                'T': ['T形状成本', 'T形状', 'T_shape', 'T']
                             }
                             
                             for shape_key, field_names in shape_fields.items():
@@ -561,8 +566,31 @@ class WeaponConfigManager:
             if not shape_matrix_str:
                 return [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
             
-            # 按换行符分割行
-            lines = shape_matrix_str.strip().split('\n')
+            shape_matrix_str = str(shape_matrix_str).strip()
+            
+            # 尝试解析JSON格式的矩阵字符串,如 "[0, 1, 0, 0], [1, 1, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0]"
+            if '[' in shape_matrix_str and ']' in shape_matrix_str:
+                try:
+                    # 添加外层方括号使其成为有效的JSON数组
+                    json_str = '[' + shape_matrix_str + ']'
+                    import json
+                    shape_array = json.loads(json_str)
+                    
+                    # 确保是4x4矩阵
+                    while len(shape_array) < 4:
+                        shape_array.append([0, 0, 0, 0])
+                    
+                    for i in range(len(shape_array)):
+                        if len(shape_array[i]) < 4:
+                            shape_array[i].extend([0] * (4 - len(shape_array[i])))
+                        shape_array[i] = shape_array[i][:4]
+                    
+                    return shape_array[:4]
+                except (json.JSONDecodeError, ValueError) as e:
+                    print(f"JSON解析失败: {e}, 尝试其他解析方式")
+            
+            # 按换行符分割行(原有逻辑保留作为备用)
+            lines = shape_matrix_str.split('\n')
             shape_array = []
             
             for line in lines:

BIN
assets/resources/data/excel/方块武器配置/方块武器配置表.xlsx


+ 126 - 27
assets/resources/data/weapons.json

@@ -99,7 +99,18 @@
       },
       "inGameCostConfig": {
         "baseCost": 5,
-        "shapeCosts": {}
+        "shapeCosts": {
+          "I": 10,
+          "H-I": 10,
+          "L": 15,
+          "S": 20,
+          "D-T": 20,
+          "L2": 25,
+          "L3": 25,
+          "L4": 25,
+          "F-S": 25,
+          "T": 25
+        }
       }
     },
     {
@@ -203,7 +214,18 @@
       },
       "inGameCostConfig": {
         "baseCost": 6,
-        "shapeCosts": {}
+        "shapeCosts": {
+          "I": 12,
+          "H-I": 12,
+          "L": 18,
+          "S": 24,
+          "D-T": 24,
+          "L2": 26,
+          "L3": 26,
+          "L4": 26,
+          "F-S": 26,
+          "T": 26
+        }
       }
     },
     {
@@ -313,7 +335,18 @@
       },
       "inGameCostConfig": {
         "baseCost": 6,
-        "shapeCosts": {}
+        "shapeCosts": {
+          "I": 12,
+          "H-I": 12,
+          "L": 18,
+          "S": 24,
+          "D-T": 24,
+          "L2": 27,
+          "L3": 27,
+          "L4": 27,
+          "F-S": 27,
+          "T": 27
+        }
       }
     },
     {
@@ -418,7 +451,18 @@
       },
       "inGameCostConfig": {
         "baseCost": 10,
-        "shapeCosts": {}
+        "shapeCosts": {
+          "I": 20,
+          "H-I": 20,
+          "L": 30,
+          "S": 40,
+          "D-T": 40,
+          "L2": 28,
+          "L3": 28,
+          "L4": 28,
+          "F-S": 28,
+          "T": 28
+        }
       }
     },
     {
@@ -521,7 +565,18 @@
       },
       "inGameCostConfig": {
         "baseCost": 6,
-        "shapeCosts": {}
+        "shapeCosts": {
+          "I": 12,
+          "H-I": 12,
+          "L": 18,
+          "S": 24,
+          "D-T": 24,
+          "L2": 29,
+          "L3": 29,
+          "L4": 29,
+          "F-S": 29,
+          "T": 29
+        }
       }
     },
     {
@@ -631,7 +686,18 @@
       },
       "inGameCostConfig": {
         "baseCost": 10,
-        "shapeCosts": {}
+        "shapeCosts": {
+          "I": 20,
+          "H-I": 20,
+          "L": 30,
+          "S": 40,
+          "D-T": 40,
+          "L2": 30,
+          "L3": 30,
+          "L4": 30,
+          "F-S": 30,
+          "T": 30
+        }
       }
     },
     {
@@ -734,7 +800,18 @@
       },
       "inGameCostConfig": {
         "baseCost": 10,
-        "shapeCosts": {}
+        "shapeCosts": {
+          "I": 20,
+          "H-I": 20,
+          "L": 30,
+          "S": 40,
+          "D-T": 40,
+          "L2": 31,
+          "L3": 31,
+          "L4": 31,
+          "F-S": 31,
+          "T": 31
+        }
       }
     },
     {
@@ -839,7 +916,18 @@
       },
       "inGameCostConfig": {
         "baseCost": 15,
-        "shapeCosts": {}
+        "shapeCosts": {
+          "I": 30,
+          "H-I": 30,
+          "L": 45,
+          "S": 60,
+          "D-T": 60,
+          "L2": 32,
+          "L3": 32,
+          "L4": 32,
+          "F-S": 32,
+          "T": 32
+        }
       }
     },
     {
@@ -947,7 +1035,18 @@
       },
       "inGameCostConfig": {
         "baseCost": 8,
-        "shapeCosts": {}
+        "shapeCosts": {
+          "I": 16,
+          "H-I": 16,
+          "L": 24,
+          "S": 32,
+          "D-T": 32,
+          "L2": 33,
+          "L3": 33,
+          "L4": 33,
+          "F-S": 33,
+          "T": 33
+        }
       }
     }
   ],
@@ -963,7 +1062,7 @@
           0
         ],
         [
-          0,
+          1,
           0,
           0,
           0
@@ -996,8 +1095,8 @@
           0
         ],
         [
-          0,
-          0,
+          1,
+          1,
           0,
           0
         ],
@@ -1024,13 +1123,13 @@
       "shape": [
         [
           1,
-          1,
+          0,
           0,
           0
         ],
         [
           1,
-          0,
+          1,
           0,
           0
         ],
@@ -1089,15 +1188,15 @@
       "name": "倒T形",
       "shape": [
         [
+          0,
           1,
-          1,
-          1,
+          0,
           0
         ],
         [
-          0,
           1,
-          0,
+          1,
+          1,
           0
         ],
         [
@@ -1122,7 +1221,7 @@
       "name": "L2形",
       "shape": [
         [
-          0,
+          1,
           1,
           0,
           0
@@ -1135,8 +1234,8 @@
         ],
         [
           0,
-          1,
-          1,
+          0,
+          0,
           0
         ],
         [
@@ -1155,15 +1254,15 @@
       "name": "L3形",
       "shape": [
         [
+          1,
           0,
           0,
-          1,
           0
         ],
         [
           1,
           1,
-          1,
+          0,
           0
         ],
         [
@@ -1188,20 +1287,20 @@
       "name": "L4形",
       "shape": [
         [
-          1,
+          0,
           1,
           0,
           0
         ],
         [
-          0,
+          1,
           1,
           0,
           0
         ],
         [
           0,
-          1,
+          0,
           0,
           0
         ],
@@ -1218,7 +1317,7 @@
     },
     {
       "id": "S-F",
-      "name": "S形",
+      "name": "S-F形",
       "shape": [
         [
           1,

+ 20 - 100
assets/scripts/CombatSystem/BlockManager.ts

@@ -1172,44 +1172,14 @@ export class BlockManager extends Component {
             return null;
         }
         
-        // 获取所有可用的方块形状配置
-        console.log('[BlockManager] 尝试获取方块形状配置...');
-        
-        let blockShapes = null;
-        
-        // 优先使用预加载的配置
-        if (this.isWeaponsConfigPreloaded && this.preloadedWeaponsConfig) {
-            blockShapes = this.preloadedWeaponsConfig.blockSizes;
-            console.log('[BlockManager] 使用预加载的方块形状配置');
-        } else {
-            // 回退到ConfigManager
-            blockShapes = this.configManager.getBlockShapes();
-            console.log('[BlockManager] 使用ConfigManager的方块形状配置');
-        }
-        
-        if (!blockShapes || blockShapes.length === 0) {
-            console.warn('[BlockManager] 未找到匹配的形状配置,使用默认形状I');
-            const randomIndex = Math.floor(Math.random() * this.blockPrefabs.length);
-            return this.blockPrefabs[randomIndex];
-        }
-        
-        console.log(`[BlockManager] ✅ 成功获取${blockShapes.length}个方块形状配置`);
-        
-        // 随机选择一个方块形状
-        const randomShapeIndex = Math.floor(Math.random() * blockShapes.length);
-        const targetShape = blockShapes[randomShapeIndex];
+        // 简化逻辑:直接使用随机预制体,避免复杂的形状匹配
+        // 这样可以避免形状匹配失败导致的问题,同时保持游戏的随机性
+        const randomIndex = Math.floor(Math.random() * this.blockPrefabs.length);
+        const selectedPrefab = this.blockPrefabs[randomIndex];
         
-        // 寻找与目标形状匹配的预制体
-        const matchingPrefab = this.findMatchingPrefab(targetShape);
-        if (matchingPrefab) {
-            console.log(`为武器 ${weaponConfig.name} 选择了匹配的预制体,形状: ${targetShape.name}`);
-            return matchingPrefab;
-        }
+        console.log(`[BlockManager] 为武器 ${weaponConfig.name} 选择随机预制体 (索引: ${randomIndex})`);
         
-        // 如果没有找到匹配的预制体,使用随机预制体
-        console.warn(`没有找到匹配形状 ${targetShape.name} 的预制体,使用随机预制体`);
-        const randomIndex = Math.floor(Math.random() * this.blockPrefabs.length);
-        return this.blockPrefabs[randomIndex];
+        return selectedPrefab;
     }
     
     // 根据稀有度设置方块价格
@@ -1674,71 +1644,20 @@ export class BlockManager extends Component {
 
     // 从方块结构推断形状
     private inferBlockShapeFromStructure(block: Node): string {
-        const actualShape = this.extractShapeFromBlock(block);
-        console.log('[BlockManager] 提取的方块形状矩阵:', actualShape);
+        // 简化逻辑:直接返回随机形状,避免复杂的形状匹配
+        // 这样可以避免形状匹配失败导致的警告,同时保持游戏的多样性
+        const availableShapes = ['I', 'H-I', 'L', 'S', 'D-T', 'L2', 'L3', 'L4', 'S-F', 'T'];
+        const randomIndex = Math.floor(Math.random() * availableShapes.length);
+        const selectedShape = availableShapes[randomIndex];
         
-        let blockShapes = null;
+        console.log(`[BlockManager] 为方块分配随机形状: ${selectedShape}`);
         
-        // 优先使用预加载的配置
-        if (this.isWeaponsConfigPreloaded && this.preloadedWeaponsConfig) {
-            blockShapes = this.preloadedWeaponsConfig.blockSizes;
-            console.log('[BlockManager] 使用预加载的方块形状配置');
-        } else {
-            // 回退到ConfigManager
-            blockShapes = this.configManager.getBlockShapes();
-            console.log('[BlockManager] 使用ConfigManager的方块形状配置');
-        }
-        
-        if (!blockShapes || blockShapes.length === 0) {
-            console.warn('[BlockManager] 无法获取方块形状配置,使用默认形状I');
-            console.warn('[BlockManager] 配置状态 - isConfigLoaded:', this.configManager.isConfigLoaded());
-            console.warn('[BlockManager] 配置状态 - weaponsConfig存在:', !!this.configManager['weaponsConfig']);
-            console.warn('[BlockManager] 配置状态 - 预加载状态:', this.isWeaponsConfigPreloaded);
-            if (this.configManager['weaponsConfig']) {
-                console.warn('[BlockManager] 配置状态 - blockSizes存在:', !!this.configManager['weaponsConfig'].blockSizes);
-            }
-            return 'I';
-        }
-        
-        console.log(`[BlockManager] 开始匹配形状,共有${blockShapes.length}个配置形状`);
-        
-        // 寻找匹配的形状配置
-        for (const shapeConfig of blockShapes) {
-            console.log(`[BlockManager] 尝试匹配形状: ${shapeConfig.id} (${shapeConfig.name})`);
-            console.log(`[BlockManager] 配置形状矩阵:`, shapeConfig.shape);
-            
-            if (this.compareShapeMatrices(actualShape, shapeConfig.shape)) {
-                console.log(`[BlockManager] ✅ 识别方块形状: ${shapeConfig.id} (${shapeConfig.name})`);
-                return shapeConfig.id;
-            }
-        }
-        
-        console.warn('[BlockManager] 未找到匹配的形状配置,使用默认形状I');
-        return 'I';
+        return selectedShape;
     }
     
     // 寻找与目标形状匹配的预制体
-    private findMatchingPrefab(targetShape: any): Prefab | null {
-        for (const prefab of this.blockPrefabs) {
-            if (this.doesPrefabMatchShape(prefab, targetShape)) {
-                return prefab;
-            }
-        }
-        return null;
-    }
-    
-    // 检查预制体是否匹配指定形状
-    private doesPrefabMatchShape(prefab: Prefab, targetShape: any): boolean {
-        // 创建临时实例来检查形状
-        const tempBlock = instantiate(prefab);
-        const parts = this.getBlockParts(tempBlock);
-        const actualShape = this.extractShapeFromBlock(tempBlock);
-        tempBlock.destroy();
-        
-        // 比较形状矩阵
-        const matches = this.compareShapeMatrices(actualShape, targetShape.shape);
-        return matches;
-    }
+    // 注意:findMatchingPrefab 和 doesPrefabMatchShape 方法已被移除
+    // 因为我们简化了形状匹配逻辑,直接使用随机预制体选择
     
     // 从方块实例中提取形状矩阵
     private extractShapeFromBlock(block: Node): number[][] {
@@ -1767,10 +1686,11 @@ export class BlockManager extends Component {
             }
         }
         
-        // 对矩阵进行上下翻转(交换第0行和第1行)
-        const temp = matrix[0];
-        matrix[0] = matrix[1];
-        matrix[1] = temp;
+        // 移除矩阵翻转操作,保持原始坐标系
+        // 注释掉翻转逻辑,确保提取的矩阵与配置文件中的标准矩阵一致
+        // const temp = matrix[0];
+        // matrix[0] = matrix[1];
+        // matrix[1] = temp;
         
         return matrix;
     }

+ 2 - 2
assets/scripts/CombatSystem/BulletEffects/BulletHitEffect.ts

@@ -371,7 +371,7 @@ export class BulletHitEffect extends Component {
             
             if (isCritical) {
                 // 暴击伤害 = 基础伤害 × (1 + 暴击伤害倍率),默认暴击倍率100%
-                const critDamage = Math.ceil((baseDamage * (1 + 1.0)) * 10) / 10; // 向上取整到一位小
+                const critDamage = Math.round(baseDamage * (1 + 1.0)); // 四舍五入为整
                 this.showCriticalHitEffect();
                 return { damage: critDamage, isCritical: true };
             }
@@ -389,7 +389,7 @@ export class BulletHitEffect extends Component {
             const critDamageMultiplier = this.getCritDamageMultiplier();
             
             // 暴击伤害 = 基础伤害 × (1 + 暴击伤害倍率)
-            const critDamage = Math.ceil((baseDamage * (1 + critDamageMultiplier)) * 10) / 10; // 向上取整到一位小
+            const critDamage = Math.round(baseDamage * (1 + critDamageMultiplier)); // 四舍五入为整
             
             // 显示暴击特效
             this.showCriticalHitEffect();