| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import pandas as pd
- # 模拟config_manager.py中的视觉配置解析逻辑
- def test_visual_config_parsing():
- # 读取Excel文件中的视觉配置
- df = pd.read_excel('d:/CocosGame/Pong/assets/resources/data/excel/方块武器配置/方块武器配置表.xlsx', sheet_name='视觉配置')
-
- print("开始解析视觉配置...")
-
- for index, row in df.iterrows():
- if index == 0: # 跳过表头
- print(f"跳过表头行 {index}")
- continue
-
- # 获取武器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"\n处理行 {index}: weapon_id = {weapon_id}")
-
- if weapon_id and str(weapon_id).strip():
- visual_config = {}
-
- # 读取武器精灵配置
- weapon_sprites = {}
- sprite_fields = {
- 'I': ['I形状精灵', 'I_sprite', 'I形状图片', 'I'],
- 'H-I': ['H-I形状精灵', 'HI_sprite', 'H-I形状图片', 'H-I'],
- 'L': ['L形状精灵', 'L_sprite', 'L形状图片', 'L'],
- 'S': ['S形状精灵', 'S_sprite', 'S形状图片', 'S'],
- 'D-T': ['D-T形状精灵', 'DT_sprite', 'D-T形状图片', 'D-T']
- }
-
- for shape, field_names in sprite_fields.items():
- for field_name in field_names:
- if field_name in row and pd.notna(row[field_name]):
- sprite_path = str(row[field_name]).strip()
- if sprite_path:
- weapon_sprites[shape] = sprite_path
- print(f" {shape}形状精灵: {sprite_path}")
- break
-
- if weapon_sprites:
- visual_config['weaponSprites'] = weapon_sprites
-
- # 读取开火音效
- fire_sound_fields = ['开火音效', 'fireSound', '射击音效', '音效']
- for field in fire_sound_fields:
- if field in row and pd.notna(row[field]):
- fire_sound = str(row[field]).strip()
- if fire_sound:
- visual_config['fireSound'] = fire_sound
- print(f" 开火音效: {fire_sound}")
- break
-
- # 读取拖尾特效
- trail_effect_fields = ['拖尾特效', 'trailEffect', '尾迹特效', '特效']
- for field in trail_effect_fields:
- if field in row and pd.notna(row[field]):
- trail_effect = str(row[field]).strip()
- if trail_effect and trail_effect.lower() != 'null':
- visual_config['trailEffect'] = trail_effect
- print(f" 拖尾特效: {trail_effect}")
- break
-
- print(f" 最终visual_config: {visual_config}")
-
- # 只处理前3个武器作为测试
- if index >= 3:
- break
- if __name__ == "__main__":
- test_visual_config_parsing()
|