diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs index 0fb50f7..ad25939 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs @@ -3,6 +3,21 @@ /// public partial class ActivityObject { + /// + /// 存放所有在表中注册的物体的id + /// + public static class Ids + { + public const string Id_role0001 = "role0001"; + public const string Id_weapon0001 = "weapon0001"; + public const string Id_bullet0001 = "bullet0001"; + public const string Id_bullet0002 = "bullet0002"; + public const string Id_shell0001 = "shell0001"; + public const string Id_other_door_e = "other_door_e"; + public const string Id_other_door_w = "other_door_w"; + public const string Id_other_door_s = "other_door_s"; + public const string Id_other_door_n = "other_door_n"; + } private static void _InitRegister() { _activityRegisterMap.Add("role0001", "res://prefab/role/Player.tscn"); diff --git a/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs b/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs index f70ee27..61a5808 100644 --- a/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs +++ b/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs @@ -33,20 +33,34 @@ { var text = File.ReadAllText("resource/config/ActivityObject.json"); var array = JsonSerializer.Deserialize[]>(text); + + var code1 = ""; + var code2 = ""; + foreach (var item in array) + { + var id = item["Id"]; + code1 += $" public const string Id_{id} = \"{id}\";\n"; + code2 += $" _activityRegisterMap.Add(\"{id}\", \"{item["Prefab"]}\");\n"; + } + var str = $"/// \n"; str += $"/// 根据配置表注册物体, 该类是自动生成的, 请不要手动编辑!\n"; str += $"/// \n"; str += $"public partial class ActivityObject\n"; str += $"{{\n"; + + str += $" /// \n"; + str += $" /// 存放所有在表中注册的物体的id\n"; + str += $" /// \n"; + str += $" public static class Ids\n"; + str += $" {{\n"; + str += code1; + str += $" }}\n"; + str += $" private static void _InitRegister()\n"; str += $" {{\n"; - - foreach (var item in array) - { - str += $" _activityRegisterMap.Add(\"{item["Id"]}\", \"{item["Prefab"]}\");\n"; - } - + str += code2; str += $" }}\n"; str += $"}}\n";