Răsfoiți Sursa

武器升级花费

181404010226 4 luni în urmă
părinte
comite
6cee4dc053

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


+ 143 - 2
assets/resources/data/excel/config_manager.py

@@ -1044,11 +1044,143 @@ class ConfigManagerGUI:
                     break
             
             if base_sheet is not None:
+                # 设置武器配置的映射
+                old_mapping = self.current_mapping
+                self.current_mapping = {
+                    'format_type': 'horizontal',
+                    'param_types': {
+                        'ID': str,
+                        '名称': str,
+                        '类型': str,
+                        '稀有度': str,
+                        '权重': int,
+                        '伤害': int,
+                        '射速': float,
+                        '射程': int,
+                        '子弹速度': int,
+                        # 英文字段支持
+                        'id': str,
+                        'name': str,
+                        'type': str,
+                        'rarity': str,
+                        'weight': int,
+                        'damage': int,
+                        'fireRate': float,
+                        'range': int,
+                        'bulletSpeed': int
+                    }
+                }
+                
                 base_config = self.parse_config_data(base_sheet, filename)
                 if 'items' in base_config:
                     weapons_config['weapons'] = base_config['items']
+                    print(f"成功解析武器基础配置,共{len(base_config['items'])}个武器")
+                
+                # 恢复原来的映射
+                self.current_mapping = old_mapping
+            
+            # 解析武器升级费用配置工作表(新增支持)
+            upgrade_cost_sheet = None
+            print(f"可用的工作表: {list(all_sheets_data.keys())}")
+            for sheet_name in ['武器升级费用配置', 'Weapon Upgrade Cost', 'upgrade_costs', '升级费用']:
+                if sheet_name in all_sheets_data:
+                    upgrade_cost_sheet = all_sheets_data[sheet_name]
+                    print(f"找到升级费用配置工作表: {sheet_name}")
+                    break
+            
+            if upgrade_cost_sheet is None:
+                print("未找到升级费用配置工作表")
+            
+            if upgrade_cost_sheet is not None:
+                # 直接处理升级费用数据(横向表格格式)
+                print(f"开始处理升级费用配置,工作表行数: {len(upgrade_cost_sheet)}")
+                upgrade_cost_data = []
+                
+                # 检查第一行是否为表头
+                first_row = upgrade_cost_sheet.iloc[0] if len(upgrade_cost_sheet) > 0 else None
+                is_header = False
+                if first_row is not None:
+                    first_cell = str(first_row.iloc[0]).strip() if len(first_row) > 0 else ""
+                    # 如果第一列是"武器ID"等表头文字,则认为是表头
+                    if first_cell in ['武器ID', 'ID', 'weapon_id', 'weaponId']:
+                        is_header = True
+                        print(f"检测到表头行,第一列内容: {first_cell}")
+                
+                for index, row in upgrade_cost_sheet.iterrows():
+                    if is_header and index == 0:  # 只有确认是表头时才跳过第一行
+                        print(f"跳过表头行 {index}")
+                        continue
+                    
+                    # 支持多种武器ID字段名:武器ID、ID、weapon_id等
+                    weapon_id = None
+                    for id_field in ['武器ID', 'ID', 'weapon_id', 'weaponId']:
+                        if id_field in row and pd.notna(row[id_field]):
+                            weapon_id = row[id_field]
+                            break
+                    
+                    # 如果没有找到命名字段,则使用第一列
+                    if weapon_id is None:
+                        weapon_id = row.iloc[0] if len(row) > 0 else None
+                    
+                    print(f"处理行 {index}: weapon_id = {weapon_id}")
+                    if weapon_id and str(weapon_id).strip():  # 确保武器ID不为空
+                        upgrade_levels = {}
+                        # 从第5列开始是等级1-10的费用(E列到N列)
+                        for level in range(1, 11):
+                            cost_col_index = 4 + (level - 1)  # 等级1费用在第5列(索引4),等级2在第6列(索引5),以此类推
+                            if cost_col_index < len(row):
+                                cost = row.iloc[cost_col_index]
+                                if cost and str(cost).strip() and str(cost) != 'nan':
+                                    try:
+                                        upgrade_levels[str(level)] = {'cost': int(float(cost))}
+                                        print(f"  等级 {level} 费用: {cost}")
+                                    except (ValueError, TypeError):
+                                        print(f"  等级 {level} 费用解析失败: {cost}")
+                        
+                        if upgrade_levels:  # 只有当有升级费用数据时才添加
+                            upgrade_cost_data.append({
+                                'weapon_id': str(weapon_id).strip(),
+                                'levels': upgrade_levels
+                            })
+                            print(f"为武器 {weapon_id} 添加了 {len(upgrade_levels)} 个等级的升级费用")
+                        else:
+                            print(f"武器 {weapon_id} 没有有效的升级费用数据")
+                
+                # 将升级费用配置合并到原始武器数据中(在转换之前)
+                print(f"总共解析到 {len(upgrade_cost_data)} 个武器的升级费用配置")
+                # 检查数据结构,支持两种格式:items 或 weapons
+                weapon_list = None
+                if 'items' in weapons_config:
+                    weapon_list = weapons_config['items']
+                    print(f"使用items字段,开始合并升级费用配置到 {len(weapon_list)} 个武器")
+                elif 'weapons' in weapons_config:
+                    weapon_list = weapons_config['weapons']
+                    print(f"使用weapons字段,开始合并升级费用配置到 {len(weapon_list)} 个武器")
+                else:
+                    print("weapons_config中没有items或weapons字段")
+                
+                if weapon_list:
+                    for weapon in weapon_list:
+                        # 支持两种字段名格式:ID(原始数据)和id(转换后数据)
+                        weapon_id = weapon.get('ID', '') or weapon.get('id', '')
+                        if weapon_id:
+                            # 查找对应的升级费用配置
+                            matching_upgrade = None
+                            for upgrade_data in upgrade_cost_data:
+                                if upgrade_data['weapon_id'] == weapon_id:
+                                    matching_upgrade = upgrade_data
+                                    break
+                            
+                            if matching_upgrade:
+                                weapon['upgradeConfig'] = {
+                                    'maxLevel': 10,
+                                    'levels': matching_upgrade['levels']
+                                }
+                                print(f"✓ 为武器 {weapon_id} 添加了升级费用配置")
+                            else:
+                                print(f"✗ 武器 {weapon_id} 未找到匹配的升级费用配置")
             
-            # 解析升级配置工作表(支持中英文工作表名)
+            # 解析旧版升级配置工作表(向后兼容
             upgrade_sheet = None
             for sheet_name in ['升级配置', 'Upgrade Config', 'upgrades', '武器升级']:
                 if sheet_name in all_sheets_data:
@@ -1065,7 +1197,7 @@ class ConfigManagerGUI:
                     # 为每个武器添加升级配置
                     for weapon in weapons_config['weapons']:
                         weapon_id = weapon.get('ID')
-                        if weapon_id:
+                        if weapon_id and 'upgradeConfig' not in weapon:  # 如果还没有升级配置
                             # 查找对应的升级配置
                             weapon_upgrades = [item for item in upgrade_items if item.get('ID') == weapon_id]
                             if weapon_upgrades:
@@ -1091,6 +1223,8 @@ class ConfigManagerGUI:
             
         except Exception as e:
             print(f"解析武器配置表时出错: {e}")
+            import traceback
+            traceback.print_exc()
             return {'weapons': []}
     
     def clear_selection(self):
@@ -1740,6 +1874,13 @@ class ConfigManagerGUI:
                 'bulletConfig': self._generate_bullet_config(weapon_id, weapon_type, damage, weapon_range),
                 'visualConfig': self._generate_visual_config(weapon_id, weapon_name)
             }
+            
+            # 如果原始数据中有upgradeConfig,则添加到结果中
+            if 'upgradeConfig' in item:
+                result['upgradeConfig'] = item['upgradeConfig']
+                print(f"为武器 {weapon_id} 保留了升级配置: {item['upgradeConfig']}")
+            else:
+                print(f"武器 {weapon_id} 没有升级配置数据")
             print(f"成功转换武器数据: {result}")
             return result
         except Exception as e:

+ 59 - 0
assets/resources/data/excel/generate_config.py

@@ -0,0 +1,59 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import pandas as pd
+import json
+from config_manager import ConfigManagerGUI
+
+def generate_weapon_config():
+    """生成武器配置文件"""
+    print("=== 开始生成武器配置 ===")
+    
+    try:
+        # 创建配置管理器实例
+        config_manager = ConfigManagerGUI()
+        
+        # 读取Excel文件
+        excel_file = "方块武器配置/方块武器配置表.xlsx"
+        all_sheets = pd.read_excel(excel_file, sheet_name=None)
+        
+        # 解析武器配置
+        weapon_config = config_manager.parse_weapon_multi_sheet_data(all_sheets, excel_file)
+        
+        # 保存到JSON文件
+        output_file = "../weapons.json"
+        with open(output_file, 'w', encoding='utf-8') as f:
+            json.dump(weapon_config, f, indent=2, ensure_ascii=False)
+        
+        print(f"配置已保存到: {output_file}")
+        print(f"共生成 {len(weapon_config.get('weapons', []))} 个武器配置")
+        
+        # 检查毛豆射手的配置
+        for weapon in weapon_config.get('weapons', []):
+            if weapon.get('ID') == 'pea_shooter' or weapon.get('id') == 'pea_shooter':
+                print("\n=== 毛豆射手配置 ===")
+                print(f"武器ID: {weapon.get('ID', weapon.get('id'))}")
+                print(f"武器名称: {weapon.get('名称', weapon.get('name'))}")
+                has_upgrade = 'upgradeConfig' in weapon
+                print(f"包含升级配置: {'是' if has_upgrade else '否'}")
+                if has_upgrade:
+                    upgrade_config = weapon['upgradeConfig']
+                    print(f"最大等级: {upgrade_config.get('maxLevel')}")
+                    levels = upgrade_config.get('levels', {})
+                    print(f"升级等级数: {len(levels)}")
+                    if levels:
+                        print("前3个等级费用:")
+                        for level in sorted(levels.keys())[:3]:
+                            cost = levels[level].get('cost', 0)
+                            print(f"  等级{level}: {cost}")
+                break
+        else:
+            print("未找到毛豆射手配置")
+            
+    except Exception as e:
+        print(f"生成配置失败: {e}")
+        import traceback
+        traceback.print_exc()
+
+if __name__ == "__main__":
+    generate_weapon_config()

+ 12 - 0
assets/resources/data/excel/generate_config.py.meta

@@ -0,0 +1,12 @@
+{
+  "ver": "1.0.0",
+  "importer": "*",
+  "imported": true,
+  "uuid": "e742795e-1cab-4597-870f-7784ac227cc8",
+  "files": [
+    ".json",
+    ".py"
+  ],
+  "subMetas": {},
+  "userData": {}
+}

+ 69 - 0
assets/resources/data/excel/test_weapon_upgrade.py

@@ -0,0 +1,69 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import pandas as pd
+import json
+from config_manager import ConfigManagerGUI
+
+def test_weapon_upgrade_parsing():
+    """测试武器升级费用配置解析"""
+    print("=== 测试武器升级费用配置解析 ===")
+    
+    # 创建配置管理器实例
+    config_manager = ConfigManagerGUI()
+    
+    # 读取Excel文件
+    excel_file = "方块武器配置/方块武器配置表.xlsx"
+    
+    try:
+        # 读取所有工作表
+        all_sheets = pd.read_excel(excel_file, sheet_name=None)
+        print(f"找到工作表: {list(all_sheets.keys())}")
+        
+        # 解析武器配置
+        weapon_config = config_manager.parse_weapon_multi_sheet_data(all_sheets, excel_file)
+        
+        print(f"\n解析结果: 共{len(weapon_config.get('weapons', []))}个武器")
+        
+        # 检查每个武器的升级配置
+        for weapon in weapon_config.get('weapons', []):
+            weapon_id = weapon.get('ID', weapon.get('id', 'Unknown'))
+            weapon_name = weapon.get('名称', weapon.get('name', 'Unknown'))
+            has_upgrade = 'upgradeConfig' in weapon
+            
+            print(f"武器: {weapon_id} ({weapon_name}) - 升级配置: {'✓' if has_upgrade else '✗'}")
+            
+            if has_upgrade:
+                upgrade_config = weapon['upgradeConfig']
+                levels = upgrade_config.get('levels', {})
+                print(f"  最大等级: {upgrade_config.get('maxLevel', 0)}")
+                print(f"  升级等级数: {len(levels)}")
+                if levels:
+                    # 显示前3个等级的费用
+                    for level in sorted(levels.keys())[:3]:
+                        cost = levels[level].get('cost', 0)
+                        print(f"  等级{level}费用: {cost}")
+            else:
+                print("  无升级配置")
+            print()
+        
+        # 特别检查毛豆射手
+        pea_shooter = None
+        for weapon in weapon_config.get('weapons', []):
+            if weapon.get('ID') == 'pea_shooter' or weapon.get('id') == 'pea_shooter':
+                pea_shooter = weapon
+                break
+        
+        if pea_shooter:
+            print("=== 毛豆射手详细信息 ===")
+            print(f"原始数据: {json.dumps(pea_shooter, indent=2, ensure_ascii=False)}")
+        else:
+            print("未找到毛豆射手配置")
+            
+    except Exception as e:
+        print(f"测试失败: {e}")
+        import traceback
+        traceback.print_exc()
+
+if __name__ == "__main__":
+    test_weapon_upgrade_parsing()

+ 12 - 0
assets/resources/data/excel/test_weapon_upgrade.py.meta

@@ -0,0 +1,12 @@
+{
+  "ver": "1.0.0",
+  "importer": "*",
+  "imported": true,
+  "uuid": "30ea841b-f27e-4e37-b615-8b5e6df0fb72",
+  "files": [
+    ".json",
+    ".py"
+  ],
+  "subMetas": {},
+  "userData": {}
+}

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


+ 1 - 1
assets/resources/data/excel/方块武器配置/~$方块武器配置表.xlsx.meta

@@ -2,7 +2,7 @@
   "ver": "1.0.0",
   "importer": "*",
   "imported": true,
-  "uuid": "1bd54b45-2df3-499a-a775-1720b8084173",
+  "uuid": "3d8519c9-255e-4d84-9807-f99d27b05ada",
   "files": [
     ".json",
     ".xlsx"

+ 0 - 106
assets/resources/data/excel/方块武器配置/字段说明文档.md

@@ -1,106 +0,0 @@
-# 方块武器配置字段说明文档
-
-## 1. weapons.csv 字段说明
-
-| 字段名 | 含义 | 类型 | 说明/可选值 |
-|--------|------|------|-------------|
-| id | 武器唯一标识 | string | 英文ID,唯一 |
-| name | 武器名称 | string | 中文名 |
-| type | 武器类型 | string | single_shot, piercing, ricochet_piercing, explosive, boomerang, area_burn, shotgun, homing_missile 等 |
-| rarity | 稀有度 | string | common, uncommon, rare, epic |
-| weight | 抽取权重 | number | 用于随机抽取概率 |
-| damage | 基础伤害 | number | 单次攻击基础伤害 |
-| fireRate | 攻击频率 | number | 每秒攻击次数 |
-| range | 攻击范围 | number | 单位:像素或格 |
-| bulletSpeed | 子弹速度 | number | 单位:像素/秒 |
-| accuracy | 命中精度 | number | 0~1,越高越准 |
-| bulletType | 子弹类型 | string | single, spread, burst 等 |
-| bulletAmount | 子弹数量 | number | 一次发射的子弹数 |
-| spreadAngle | 散射角度 | number | 单位:度 |
-| burstCount | 连发数量 | number | burst模式下的连发数 |
-| burstDelay | 连发间隔 | number | 单位:秒 |
-| trajectoryType | 弹道类型 | string | straight, arc, homing_arc |
-| bulletSpeed | 子弹速度 | number | 单位:像素/秒 |
-| gravity | 重力影响 | number | 仅arc弹道有效 |
-| arcHeight | 抛物线高度 | number | 仅arc弹道有效 |
-| homingStrength | 导弹追踪强度 | number | 仅homing弹道有效 |
-| homingDelay | 追踪延迟 | number | 仅homing弹道有效 |
-| hitEffectType | 命中效果类型 | string | normal_damage, pierce_damage, explosion, ground_burn, ricochet_damage 等 |
-| hitEffectDamage | 命中伤害 | number | 命中时造成的伤害 |
-| hitEffectRadius | 效果半径 | number | 范围伤害半径 |
-| hitEffectDuration | 效果持续时间 | number | 持续型效果时长 |
-| lifecycleType | 生命周期类型 | string | hit_destroy, range_limit, ricochet_counter, ground_impact, return_trip, ground_impact_with_effect, target_impact |
-| maxLifetime | 最大存活时间 | number | 单位:秒 |
-| penetration | 穿透数 | number | 可穿透敌人数 |
-| ricochetCount | 弹射次数 | number | 可弹射的最大次数 |
-| returnToOrigin | 是否回弹 | bool | boomerang等武器专用 |
-| bulletPrefab | 子弹预制体路径 | string | 资源路径 |
-| hitEffect | 命中特效路径 | string | 资源路径 |
-| trailEffect | 子弹拖尾特效路径 | string | 资源路径 |
-| muzzleFlash | 枪口火焰特效路径 | string | 资源路径 |
-| weaponSprite1x1 | 1x1尺寸武器图标 | string | 资源路径 |
-| weaponSprite1x2 | 1x2尺寸武器图标 | string | 资源路径 |
-| weaponSprite2x1 | 2x1尺寸武器图标 | string | 资源路径 |
-| weaponSprite2x2 | 2x2尺寸武器图标 | string | 资源路径 |
-| fireSound | 开火音效 | string | 资源路径 |
-
-## 2. blockSizes.csv 字段说明
-
-| 字段名 | 含义 | 说明 |
-|--------|------|------|
-| blockSize | 方块尺寸 | 可选值:1x1, 1x2, 2x1, 2x2 |
-
-## 3. rarityWeights.csv 字段说明
-
-| 字段名 | 含义 | 说明/可选值 |
-|--------|------|-------------|
-| rarity | 稀有度 | common, uncommon, rare, epic |
-| weight | 权重 | 用于随机抽取概率 |
-
-## 4. bulletEffectTypes.csv 字段说明
-
-| 字段类型 | 可选值 |
-|----------|--------|
-| count | single, spread, burst |
-| 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 |
-
----
-1. count (计数/发射方式)
-控制武器如何发射子弹:
-single: 单发 - 每次射击只发射一颗子弹
-spread: 散射 - 一次射击发射多颗子弹,呈扇形散开(如霰弹枪)
-burst: 连发 - 一次射击连续快速发射多颗子弹(如冲锋枪短点射)
-2. trajectory (弹道/轨迹)
-控制子弹的飞行路径:
-straight: 直线 - 子弹沿直线飞行
-arc: 弧线 - 子弹沿抛物线飞行,受重力影响
-homing_arc: 追踪弧线 - 子弹沿弧线飞行并能追踪目标
-3. hitEffects (命中效果)
-控制子弹命中目标后的效果:
-normal_damage: 普通伤害 - 标准伤害效果
-pierce_damage: 穿透伤害 - 子弹可穿透多个目标
-explosion: 爆炸 - 命中后发生爆炸,范围伤害
-ground_burn: 地面燃烧 - 在地面留下燃烧效果
-ricochet_damage: 跳弹伤害 - 子弹会反弹并再次造成伤害
-4. lifecycle (生命周期)
-控制子弹何时消失:
-hit_destroy: 命中销毁 - 命中任何物体后立即消失
-range_limit: 射程限制 - 达到最大射程后消失
-ricochet_counter: 跳弹计数 - 反弹有限次数后消失
-ground_impact: 落地 - 受重力影响最终落地
-return_trip: 返回 - 达到目标后返回发射点
-ground_impact_with_effect: 落地带效果 - 落地后触发额外效果
-target_impact: 目标命中 - 命中预定目标后消失
-这些属性组合使用可以创建各种不同的武器效果,比如:
-穿透型武器:pierce_damage + range_limit
-爆炸型武器:explosion + ground_impact
-回旋镖武器:pierce_damage + return_trip
-追踪导弹:explosion + target_impact + homing_arc
-
-### 使用建议
-- 编辑CSV时请勿更改表头字段名。
-- 字段值需符合类型和可选值要求。
-- 资源路径需与实际项目资源一致。
-- 可根据实际需求扩展字段,但需同步更新说明文档。 

+ 0 - 11
assets/resources/data/excel/方块武器配置/字段说明文档.md.meta

@@ -1,11 +0,0 @@
-{
-  "ver": "1.0.1",
-  "importer": "text",
-  "imported": true,
-  "uuid": "8c06977c-f8ce-45e2-a8dd-777fb3a1c735",
-  "files": [
-    ".json"
-  ],
-  "subMetas": {},
-  "userData": {}
-}

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


+ 300 - 208
assets/resources/data/weapons.json

@@ -10,7 +10,7 @@
         "damage": 20,
         "fireRate": 1.0,
         "range": 300,
-        "bulletSpeed": 50
+        "bulletSpeed": 30
       },
       "bulletConfig": {
         "count": {
@@ -60,6 +60,41 @@
           "D-T": "images/PlantsSprite/001-1"
         },
         "fireSound": "audio/pea_shooter_shot"
+      },
+      "upgradeConfig": {
+        "maxLevel": 10,
+        "levels": {
+          "1": {
+            "cost": 50
+          },
+          "2": {
+            "cost": 100
+          },
+          "3": {
+            "cost": 200
+          },
+          "4": {
+            "cost": 400
+          },
+          "5": {
+            "cost": 800
+          },
+          "6": {
+            "cost": 1600
+          },
+          "7": {
+            "cost": 3200
+          },
+          "8": {
+            "cost": 6400
+          },
+          "9": {
+            "cost": 12800
+          },
+          "10": {
+            "cost": 25600
+          }
+        }
       }
     },
     {
@@ -67,12 +102,12 @@
       "name": "尖胡萝卜",
       "type": "piercing",
       "rarity": "common",
-      "weight": 30,
+      "weight": 25,
       "stats": {
         "damage": 15,
         "fireRate": 0.8,
         "range": 400,
-        "bulletSpeed": 50
+        "bulletSpeed": 30
       },
       "bulletConfig": {
         "count": {
@@ -124,6 +159,41 @@
           "D-T": "images/PlantsSprite/002"
         },
         "fireSound": "audio/sharp_carrot_shot"
+      },
+      "upgradeConfig": {
+        "maxLevel": 10,
+        "levels": {
+          "1": {
+            "cost": 60
+          },
+          "2": {
+            "cost": 120
+          },
+          "3": {
+            "cost": 240
+          },
+          "4": {
+            "cost": 480
+          },
+          "5": {
+            "cost": 960
+          },
+          "6": {
+            "cost": 1920
+          },
+          "7": {
+            "cost": 3840
+          },
+          "8": {
+            "cost": 7680
+          },
+          "9": {
+            "cost": 15360
+          },
+          "10": {
+            "cost": 30720
+          }
+        }
       }
     },
     {
@@ -136,7 +206,7 @@
         "damage": 25,
         "fireRate": 0.6,
         "range": 350,
-        "bulletSpeed": 50
+        "bulletSpeed": 30
       },
       "bulletConfig": {
         "count": {
@@ -196,6 +266,41 @@
           "D-T": "images/PlantsSprite/003"
         },
         "fireSound": "audio/saw_grass_shot"
+      },
+      "upgradeConfig": {
+        "maxLevel": 10,
+        "levels": {
+          "1": {
+            "cost": 80
+          },
+          "2": {
+            "cost": 160
+          },
+          "3": {
+            "cost": 320
+          },
+          "4": {
+            "cost": 640
+          },
+          "5": {
+            "cost": 1280
+          },
+          "6": {
+            "cost": 2560
+          },
+          "7": {
+            "cost": 5120
+          },
+          "8": {
+            "cost": 10240
+          },
+          "9": {
+            "cost": 20480
+          },
+          "10": {
+            "cost": 40960
+          }
+        }
       }
     },
     {
@@ -208,7 +313,7 @@
         "damage": 50,
         "fireRate": 0.4,
         "range": 250,
-        "bulletSpeed": 50
+        "bulletSpeed": 30
       },
       "bulletConfig": {
         "count": {
@@ -260,6 +365,41 @@
           "D-T": "images/PlantsSprite/007"
         },
         "fireSound": "audio/watermelon_bomb_shot"
+      },
+      "upgradeConfig": {
+        "maxLevel": 10,
+        "levels": {
+          "1": {
+            "cost": 150
+          },
+          "2": {
+            "cost": 300
+          },
+          "3": {
+            "cost": 600
+          },
+          "4": {
+            "cost": 1200
+          },
+          "5": {
+            "cost": 2400
+          },
+          "6": {
+            "cost": 4800
+          },
+          "7": {
+            "cost": 9600
+          },
+          "8": {
+            "cost": 19200
+          },
+          "9": {
+            "cost": 38400
+          },
+          "10": {
+            "cost": 76800
+          }
+        }
       }
     },
     {
@@ -267,12 +407,12 @@
       "name": "回旋镖盆栽",
       "type": "boomerang",
       "rarity": "uncommon",
-      "weight": 20,
+      "weight": 18,
       "stats": {
         "damage": 30,
         "fireRate": 0.5,
         "range": 300,
-        "bulletSpeed": 50
+        "bulletSpeed": 30
       },
       "bulletConfig": {
         "count": {
@@ -323,19 +463,54 @@
           "D-T": "images/PlantsSprite/004"
         },
         "fireSound": "audio/boomerang_plant_shot"
+      },
+      "upgradeConfig": {
+        "maxLevel": 10,
+        "levels": {
+          "1": {
+            "cost": 100
+          },
+          "2": {
+            "cost": 200
+          },
+          "3": {
+            "cost": 400
+          },
+          "4": {
+            "cost": 800
+          },
+          "5": {
+            "cost": 1600
+          },
+          "6": {
+            "cost": 3200
+          },
+          "7": {
+            "cost": 6400
+          },
+          "8": {
+            "cost": 12800
+          },
+          "9": {
+            "cost": 25600
+          },
+          "10": {
+            "cost": 51200
+          }
+        }
       }
     },
     {
       "id": "hot_pepper",
       "name": "炙热辣椒",
-      "type": "explosive",
+      "type": "area_burn",
       "rarity": "rare",
-      "weight": 15,
+      "weight": 12,
       "stats": {
         "damage": 40,
         "fireRate": 0.3,
         "range": 280,
-        "bulletSpeed": 50
+        "bulletSpeed": 30
       },
       "bulletConfig": {
         "count": {
@@ -346,7 +521,7 @@
           "burstDelay": 0
         },
         "trajectory": {
-          "type": "arc",
+          "type": "straight",
           "speed": 200,
           "gravity": 0,
           "arcHeight": 0,
@@ -355,17 +530,15 @@
         },
         "hitEffects": [
           {
-            "type": "explosion",
+            "type": "normal_damage",
             "priority": 1,
             "params": {
-              "damage": 60,
-              "radius": 100,
-              "delay": 0.1
+              "damage": 40
             }
           }
         ],
         "lifecycle": {
-          "type": "ground_impact",
+          "type": "hit_destroy",
           "maxLifetime": 5.0,
           "penetration": 1,
           "ricochetCount": 0,
@@ -373,7 +546,7 @@
         },
         "visual": {
           "bulletPrefab": "bullets/Hot_PepperBullet",
-          "hitEffect": "Animation/WeaponTx/tx0007/tx0007",
+          "hitEffect": "Animation/WeaponTx/tx0002/tx0002",
           "trailEffect": null,
           "muzzleFlash": "Animation/WeaponTx/tx0002/tx0002"
         }
@@ -387,19 +560,54 @@
           "D-T": "images/PlantsSprite/005"
         },
         "fireSound": "audio/hot_pepper_shot"
+      },
+      "upgradeConfig": {
+        "maxLevel": 10,
+        "levels": {
+          "1": {
+            "cost": 140
+          },
+          "2": {
+            "cost": 280
+          },
+          "3": {
+            "cost": 560
+          },
+          "4": {
+            "cost": 1120
+          },
+          "5": {
+            "cost": 2240
+          },
+          "6": {
+            "cost": 4480
+          },
+          "7": {
+            "cost": 8960
+          },
+          "8": {
+            "cost": 17920
+          },
+          "9": {
+            "cost": 35840
+          },
+          "10": {
+            "cost": 71680
+          }
+        }
       }
     },
     {
       "id": "cactus_shotgun",
       "name": "仙人散弹",
       "type": "shotgun",
-      "rarity": "common",
-      "weight": 30,
+      "rarity": "uncommon",
+      "weight": 22,
       "stats": {
         "damage": 12,
         "fireRate": 0.7,
         "range": 200,
-        "bulletSpeed": 50
+        "bulletSpeed": 30
       },
       "bulletConfig": {
         "count": {
@@ -450,6 +658,41 @@
           "D-T": "images/PlantsSprite/008"
         },
         "fireSound": "audio/cactus_shotgun_shot"
+      },
+      "upgradeConfig": {
+        "maxLevel": 10,
+        "levels": {
+          "1": {
+            "cost": 70
+          },
+          "2": {
+            "cost": 140
+          },
+          "3": {
+            "cost": 280
+          },
+          "4": {
+            "cost": 560
+          },
+          "5": {
+            "cost": 1120
+          },
+          "6": {
+            "cost": 2240
+          },
+          "7": {
+            "cost": 4480
+          },
+          "8": {
+            "cost": 8960
+          },
+          "9": {
+            "cost": 17920
+          },
+          "10": {
+            "cost": 35840
+          }
+        }
       }
     },
     {
@@ -462,7 +705,7 @@
         "damage": 70,
         "fireRate": 0.25,
         "range": 500,
-        "bulletSpeed": 50
+        "bulletSpeed": 30
       },
       "bulletConfig": {
         "count": {
@@ -514,193 +757,42 @@
           "D-T": "images/PlantsSprite/006"
         },
         "fireSound": "audio/okra_missile_shot"
+      },
+      "upgradeConfig": {
+        "maxLevel": 10,
+        "levels": {
+          "1": {
+            "cost": 200
+          },
+          "2": {
+            "cost": 400
+          },
+          "3": {
+            "cost": 800
+          },
+          "4": {
+            "cost": 1600
+          },
+          "5": {
+            "cost": 3200
+          },
+          "6": {
+            "cost": 6400
+          },
+          "7": {
+            "cost": 12800
+          },
+          "8": {
+            "cost": 25600
+          },
+          "9": {
+            "cost": 51200
+          },
+          "10": {
+            "cost": 102400
+          }
+        }
       }
     }
-  ],
-  "rarityWeights": {
-    "common": 60,
-    "uncommon": 25,
-    "rare": 12,
-    "epic": 3
-  },
-  "blockSizes": [
-    {
-      "id": "I",
-      "name": "竖条",
-      "shape": [
-        [
-          1,
-          0,
-          0,
-          0
-        ],
-        [
-          1,
-          0,
-          0,
-          0
-        ],
-        [
-          0,
-          0,
-          0,
-          0
-        ],
-        [
-          0,
-          0,
-          0,
-          0
-        ]
-      ]
-    },
-    {
-      "id": "H-I",
-      "name": "横I型",
-      "shape": [
-        [
-          0,
-          0,
-          0,
-          0
-        ],
-        [
-          1,
-          1,
-          0,
-          0
-        ],
-        [
-          0,
-          0,
-          0,
-          0
-        ],
-        [
-          0,
-          0,
-          0,
-          0
-        ]
-      ]
-    },
-    {
-      "id": "L",
-      "name": "L型",
-      "shape": [
-        [
-          1,
-          1,
-          0,
-          0
-        ],
-        [
-          1,
-          0,
-          0,
-          0
-        ],
-        [
-          0,
-          0,
-          0,
-          0
-        ],
-        [
-          0,
-          0,
-          0,
-          0
-        ]
-      ]
-    },
-    {
-      "id": "S",
-      "name": "S型",
-      "shape": [
-        [
-          0,
-          1,
-          1,
-          0
-        ],
-        [
-          1,
-          1,
-          0,
-          0
-        ],
-        [
-          0,
-          0,
-          0,
-          0
-        ],
-        [
-          0,
-          0,
-          0,
-          0
-        ]
-      ]
-    },
-    {
-      "id": "D-T",
-      "name": "倒T型",
-      "shape": [
-        [
-          0,
-          1,
-          0,
-          0
-        ],
-        [
-          1,
-          1,
-          1,
-          0
-        ],
-        [
-          0,
-          0,
-          0,
-          0
-        ],
-        [
-          0,
-          0,
-          0,
-          0
-        ]
-      ]
-    }
-  ],
-  "bulletEffectTypes": {
-    "count": [
-      "single",
-      "spread",
-      "burst"
-    ],
-    "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"
-    ]
-  }
+  ]
 }

+ 38 - 5
assets/scripts/FourUI/UpgradeSystem/UpgradeController.ts

@@ -29,6 +29,14 @@ interface WeaponConfig {
             "D-T": string;
         };
     };
+    upgradeConfig?: {
+        maxLevel: number;
+        levels: {
+            [level: string]: {
+                cost: number;
+            };
+        };
+    };
 }
 
 /**
@@ -417,7 +425,7 @@ export class UpgradeController extends Component {
             // 设置按钮文本和状态
             const buttonLabel = upgradeButton.node.getChildByName('Label')?.getComponent(Label);
             if (buttonLabel) {
-                const maxLevel = 10; // 假设最大等级为10
+                const maxLevel = weaponConfig.upgradeConfig?.maxLevel || 10;
                 
                 if (weaponData && weaponData.level >= maxLevel) {
                     buttonLabel.string = '已满级';
@@ -543,9 +551,33 @@ export class UpgradeController extends Component {
         }
         
         // 设置升级费用 - Canvas/UpgradeUI/UpgradePanel/UpgradeBtn/CostLabel
-        const upgradeCost = this.saveDataManager.getWeaponUpgradeCost(this.currentSelectedWeapon);
-        if (this.panelCostLabel) {
-            this.panelCostLabel.string = upgradeCost.toString();
+        // 优先从武器配置的upgradeConfig字段获取升级费用
+        let upgradeCost = 0;
+        const maxLevel = weaponConfig.upgradeConfig?.maxLevel || 10;
+        
+        if (weaponData.level >= maxLevel) {
+            // 已达到最大等级,显示"已满级"
+            if (this.panelCostLabel) {
+                this.panelCostLabel.string = "已满级";
+            }
+        } else {
+            // 从upgradeConfig获取升级费用
+            if (weaponConfig.upgradeConfig?.levels) {
+                const levelConfig = weaponConfig.upgradeConfig.levels[weaponData.level.toString()];
+                if (levelConfig && levelConfig.cost) {
+                    upgradeCost = levelConfig.cost;
+                } else {
+                    // 如果upgradeConfig中没有对应等级的费用,使用SaveDataManager的计算方法作为后备
+                    upgradeCost = this.saveDataManager.getWeaponUpgradeCost(this.currentSelectedWeapon);
+                }
+            } else {
+                // 如果没有upgradeConfig,使用SaveDataManager的计算方法
+                upgradeCost = this.saveDataManager.getWeaponUpgradeCost(this.currentSelectedWeapon);
+            }
+            
+            if (this.panelCostLabel) {
+                this.panelCostLabel.string = upgradeCost.toString();
+            }
         }
         
         // 升级按钮始终保持可点击状态,通过Toast显示各种提示
@@ -652,7 +684,8 @@ export class UpgradeController extends Component {
         }
         
         // 检查是否已达到最大等级
-        const maxLevel = 10; // 假设最大等级为10
+        const weaponConfig = this.weaponsConfig.weapons.find(w => w.id === this.currentSelectedWeapon);
+        const maxLevel = weaponConfig?.upgradeConfig?.maxLevel || 10;
         if (weapon.level >= maxLevel) {
             console.log(`[UpgradeController] 武器已达到最大等级: ${this.currentSelectedWeapon}`);
             EventBus.getInstance().emit(GameEvents.SHOW_TOAST, { message: "武器已达到最大等级", duration: 2.0 });