debug_visual_config.py 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import pandas as pd
  2. # 模拟config_manager.py中的视觉配置解析逻辑
  3. def test_visual_config_parsing():
  4. # 读取Excel文件中的视觉配置
  5. df = pd.read_excel('d:/CocosGame/Pong/assets/resources/data/excel/方块武器配置/方块武器配置表.xlsx', sheet_name='视觉配置')
  6. print("开始解析视觉配置...")
  7. for index, row in df.iterrows():
  8. if index == 0: # 跳过表头
  9. print(f"跳过表头行 {index}")
  10. continue
  11. # 获取武器ID
  12. weapon_id = None
  13. for id_field in ['武器ID', 'ID', 'weapon_id', 'weaponId']:
  14. if id_field in row and pd.notna(row[id_field]):
  15. weapon_id = row[id_field]
  16. break
  17. if weapon_id is None:
  18. weapon_id = row.iloc[0] if len(row) > 0 else None
  19. print(f"\n处理行 {index}: weapon_id = {weapon_id}")
  20. if weapon_id and str(weapon_id).strip():
  21. visual_config = {}
  22. # 读取武器精灵配置
  23. weapon_sprites = {}
  24. sprite_fields = {
  25. 'I': ['I形状精灵', 'I_sprite', 'I形状图片', 'I'],
  26. 'H-I': ['H-I形状精灵', 'HI_sprite', 'H-I形状图片', 'H-I'],
  27. 'L': ['L形状精灵', 'L_sprite', 'L形状图片', 'L'],
  28. 'S': ['S形状精灵', 'S_sprite', 'S形状图片', 'S'],
  29. 'D-T': ['D-T形状精灵', 'DT_sprite', 'D-T形状图片', 'D-T']
  30. }
  31. for shape, field_names in sprite_fields.items():
  32. for field_name in field_names:
  33. if field_name in row and pd.notna(row[field_name]):
  34. sprite_path = str(row[field_name]).strip()
  35. if sprite_path:
  36. weapon_sprites[shape] = sprite_path
  37. print(f" {shape}形状精灵: {sprite_path}")
  38. break
  39. if weapon_sprites:
  40. visual_config['weaponSprites'] = weapon_sprites
  41. # 读取开火音效
  42. fire_sound_fields = ['开火音效', 'fireSound', '射击音效', '音效']
  43. for field in fire_sound_fields:
  44. if field in row and pd.notna(row[field]):
  45. fire_sound = str(row[field]).strip()
  46. if fire_sound:
  47. visual_config['fireSound'] = fire_sound
  48. print(f" 开火音效: {fire_sound}")
  49. break
  50. # 读取拖尾特效
  51. trail_effect_fields = ['拖尾特效', 'trailEffect', '尾迹特效', '特效']
  52. for field in trail_effect_fields:
  53. if field in row and pd.notna(row[field]):
  54. trail_effect = str(row[field]).strip()
  55. if trail_effect and trail_effect.lower() != 'null':
  56. visual_config['trailEffect'] = trail_effect
  57. print(f" 拖尾特效: {trail_effect}")
  58. break
  59. print(f" 最终visual_config: {visual_config}")
  60. # 只处理前3个武器作为测试
  61. if index >= 3:
  62. break
  63. if __name__ == "__main__":
  64. test_visual_config_parsing()