diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/BuffGenerator.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/BuffGenerator.cs new file mode 100644 index 0000000..6ae6634 --- /dev/null +++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/BuffGenerator.cs @@ -0,0 +1,130 @@ +#if TOOLS +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using Godot; + +namespace Generator; + +/// +/// 生成 Buff 属性表 +/// +public static class BuffGenerator +{ + private const string SavePath = "src/game/manager/BuffRegister.cs"; + + public static bool Generate() + { + try + { + var buffInfos = new Dictionary(); + var types = typeof(BuffGenerator).Assembly.GetTypes(); + //包含[BuffAttribute]特性 + var enumerable = types.Where(type => + type.IsClass && !type.IsAbstract && type.IsAssignableTo(typeof(BuffFragment))); + foreach (var type in enumerable) + { + var attribute = (BuffAttribute)type.GetCustomAttribute(typeof(BuffAttribute), false); + if (attribute != null) + { + if (buffInfos.ContainsKey(attribute.BuffName)) + { + GD.PrintErr($"Buff '{attribute.BuffName}' 重名!"); + return false; + } + var buffInfo = new BuffInfo(attribute.BuffName, attribute.Description, type); + buffInfos.Add(attribute.BuffName, buffInfo); + //判断重写参数情况 + //1参数 + var methodInfo1 = type.GetMethod(nameof(BuffFragment.InitParam), + BindingFlags.Instance | BindingFlags.Public, new Type[] { typeof(float) }); + if (methodInfo1 != null && + methodInfo1.GetBaseDefinition().DeclaringType != methodInfo1.DeclaringType) + { + buffInfo.Params.Add(1); + } + + //2参数 + var methodInfo2 = type.GetMethod(nameof(BuffFragment.InitParam), + BindingFlags.Instance | BindingFlags.Public, new Type[] { typeof(float), typeof(float) }); + if (methodInfo2 != null && + methodInfo2.GetBaseDefinition().DeclaringType != methodInfo2.DeclaringType) + { + buffInfo.Params.Add(2); + } + + //3参数 + var methodInfo3 = type.GetMethod(nameof(BuffFragment.InitParam), + BindingFlags.Instance | BindingFlags.Public, + new Type[] { typeof(float), typeof(float), typeof(float) }); + if (methodInfo3 != null && + methodInfo3.GetBaseDefinition().DeclaringType != methodInfo3.DeclaringType) + { + buffInfo.Params.Add(3); + } + + //4参数 + var methodInfo4 = type.GetMethod(nameof(BuffFragment.InitParam), + BindingFlags.Instance | BindingFlags.Public, + new Type[] { typeof(float), typeof(float), typeof(float), typeof(float) }); + if (methodInfo4 != null && + methodInfo4.GetBaseDefinition().DeclaringType != methodInfo4.DeclaringType) + { + buffInfo.Params.Add(4); + } + } + } + + GenerateCode(buffInfos); + } + catch (Exception e) + { + GD.PrintErr(e.Message + "\n" + e.StackTrace); + return false; + } + + return true; + } + + private static void GenerateCode(Dictionary buffInfo) + { + var str = ""; + foreach (var kv in buffInfo) + { + var info = kv.Value; + var s = ""; + for (var i = 0; i < info.Params.Count; i++) + { + if (i > 0) s += ", "; + s += info.Params[i]; + } + + str += $" BuffInfos.Add(\"{info.Name}\", new BuffInfo(\"{info.Name}\", null, new List() {{ {s} }}, typeof({info.Type.FullName})));\n"; + } + + var code = $"using System.Collections.Generic;\n" + + $"/// \n" + + $"/// buff 注册类, 调用 Init() 函数初始化数据\n" + + $"/// 注意: 该类为 Tools 面板下自动生成的, 请不要手动编辑!\n" + + $"/// \n" + + $"public class BuffRegister\n" + + $"{{\n" + + $" /// \n" + + $" /// 所有 buff 信息\n" + + $" /// \n" + + $" public static Dictionary BuffInfos {{ get; private set; }}\n" + + $" /// \n" + + $" /// 初始化 buff\n" + + $" /// \n" + + $" public static void Init()\n" + + $" {{\n" + + $" BuffInfos = new Dictionary();\n" + + str + + $" }}\n" + + $"}}"; + File.WriteAllText(SavePath, code); + } +} +#endif diff --git a/DungeonShooting_Godot/excel/ActivityBase.xlsx b/DungeonShooting_Godot/excel/ActivityBase.xlsx index 0eec9a2..4aca08f 100644 --- a/DungeonShooting_Godot/excel/ActivityBase.xlsx +++ b/DungeonShooting_Godot/excel/ActivityBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/BuffBase.xlsx b/DungeonShooting_Godot/excel/BuffBase.xlsx new file mode 100644 index 0000000..6ec3209 --- /dev/null +++ b/DungeonShooting_Godot/excel/BuffBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/prefab/prop/BuffActivity.tscn b/DungeonShooting_Godot/prefab/prop/BuffActivity.tscn new file mode 100644 index 0000000..1e55321 --- /dev/null +++ b/DungeonShooting_Godot/prefab/prop/BuffActivity.tscn @@ -0,0 +1,52 @@ +[gd_scene load_steps=7 format=3 uid="uid://dfpic4nubu7cf"] + +[ext_resource type="Script" path="res://src/game/activity/prop/BuffActivity.cs" id="1_3ya6n"] +[ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_p5e2l"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_mrkt4"] +resource_local_to_scene = true +shader = ExtResource("2_p5e2l") +shader_parameter/blend = Color(0, 0, 0, 0.470588) +shader_parameter/schedule = 1.0 +shader_parameter/modulate = Color(1, 1, 1, 1) +shader_parameter/show_outline = false +shader_parameter/outline_color = Color(0, 0, 0, 1) +shader_parameter/outline_rainbow = false +shader_parameter/outline_use_blend = true +shader_parameter/grey = 0.0 + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_b6ii6"] +resource_local_to_scene = true +shader = ExtResource("2_p5e2l") +shader_parameter/blend = Color(1, 1, 1, 1) +shader_parameter/schedule = 0.0 +shader_parameter/modulate = Color(1, 1, 1, 1) +shader_parameter/show_outline = true +shader_parameter/outline_color = Color(0, 0, 0, 1) +shader_parameter/outline_rainbow = false +shader_parameter/outline_use_blend = true +shader_parameter/grey = 0.0 + +[sub_resource type="SpriteFrames" id="SpriteFrames_y5dlc"] +resource_local_to_scene = true + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_cpqup"] +size = Vector2(12, 10) + +[node name="BuffActivity" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")] +collision_layer = 4 +script = ExtResource("1_3ya6n") +ShadowSprite = NodePath("ShadowSprite") +AnimatedSprite = NodePath("AnimatedSprite") +Collision = NodePath("Collision") + +[node name="ShadowSprite" type="Sprite2D" parent="."] +z_index = -1 +material = SubResource("ShaderMaterial_mrkt4") + +[node name="AnimatedSprite" type="AnimatedSprite2D" parent="."] +material = SubResource("ShaderMaterial_b6ii6") +sprite_frames = SubResource("SpriteFrames_y5dlc") + +[node name="Collision" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_cpqup") diff --git a/DungeonShooting_Godot/resource/config/ActivityBase.json b/DungeonShooting_Godot/resource/config/ActivityBase.json index 864f66b..7fb29f0 100644 --- a/DungeonShooting_Godot/resource/config/ActivityBase.json +++ b/DungeonShooting_Godot/resource/config/ActivityBase.json @@ -1,8 +1,8 @@ [ { "Id": "role0001", - "Type": 3, "Name": "\u73A9\u5BB6", + "Type": 3, "Quality": 0, "Price": 0, "Intro": "\u73A9\u5BB6", @@ -15,8 +15,8 @@ }, { "Id": "enemy0001", - "Type": 4, "Name": "\u654C\u4EBA", + "Type": 4, "Quality": 0, "Price": 0, "Intro": "\u654C\u4EBA", @@ -29,8 +29,8 @@ }, { "Id": "enemy0002", - "Type": 4, "Name": "\u654C\u4EBA2", + "Type": 4, "Quality": 0, "Price": 0, "Intro": "\u654C\u4EBA2", @@ -43,8 +43,8 @@ }, { "Id": "weapon0001", - "Type": 5, "Name": "\u6B65\u67AA", + "Type": 5, "Quality": 3, "Price": 0, "Intro": "", @@ -57,8 +57,8 @@ }, { "Id": "weapon0002", - "Type": 5, "Name": "\u9730\u5F39\u67AA", + "Type": 5, "Quality": 3, "Price": 0, "Intro": "", @@ -71,8 +71,8 @@ }, { "Id": "weapon0003", - "Type": 5, "Name": "\u624B\u67AA", + "Type": 5, "Quality": 2, "Price": 0, "Intro": "", @@ -85,8 +85,8 @@ }, { "Id": "weapon0004", - "Type": 5, "Name": "\u5200", + "Type": 5, "Quality": 4, "Price": 0, "Intro": "", @@ -99,8 +99,8 @@ }, { "Id": "weapon0005", - "Type": 5, "Name": "\u72D9\u51FB\u67AA", + "Type": 5, "Quality": 4, "Price": 0, "Intro": "", @@ -113,8 +113,8 @@ }, { "Id": "weapon0006", - "Type": 5, "Name": "\u51B2\u950B\u67AA", + "Type": 5, "Quality": 2, "Price": 0, "Intro": "", @@ -127,8 +127,8 @@ }, { "Id": "weapon0007", - "Type": 5, "Name": "\u6C64\u59C6\u900A\u51B2\u950B\u67AA", + "Type": 5, "Quality": 4, "Price": 0, "Intro": "", @@ -141,8 +141,8 @@ }, { "Id": "weapon0008", - "Type": 5, "Name": "\u6FC0\u5149\u624B\u67AA", + "Type": 5, "Quality": 3, "Price": 0, "Intro": "", @@ -155,8 +155,8 @@ }, { "Id": "weapon0009", - "Type": 5, "Name": "\u69B4\u5F39\u53D1\u5C04\u5668", + "Type": 5, "Quality": 4, "Price": 0, "Intro": "", @@ -169,8 +169,8 @@ }, { "Id": "weapon0010", - "Type": 5, "Name": "M1\u578B\u70ED\u80FD\u72D9\u51FB\u67AA", + "Type": 5, "Quality": 5, "Price": 0, "Intro": "", @@ -183,8 +183,8 @@ }, { "Id": "weapon0011", - "Type": 5, "Name": "weapon0011", + "Type": 5, "Quality": 5, "Price": 0, "Intro": "", @@ -197,8 +197,8 @@ }, { "Id": "weapon0013", - "Type": 5, "Name": "P90", + "Type": 5, "Quality": 4, "Price": 0, "Intro": "", @@ -211,8 +211,8 @@ }, { "Id": "weapon0014", - "Type": 5, "Name": "\u5DE6\u8F6E", + "Type": 5, "Quality": 2, "Price": 0, "Intro": "", @@ -225,8 +225,8 @@ }, { "Id": "weapon0016", - "Type": 5, "Name": "\u6728\u8D28\u77ED\u5F13", + "Type": 5, "Quality": 2, "Price": 0, "Intro": "", @@ -239,8 +239,8 @@ }, { "Id": "bullet0001", - "Type": 6, "Name": "", + "Type": 6, "Quality": 0, "Price": 0, "Intro": "", @@ -253,8 +253,8 @@ }, { "Id": "bullet0002", - "Type": 6, "Name": "", + "Type": 6, "Quality": 0, "Price": 0, "Intro": "", @@ -267,8 +267,8 @@ }, { "Id": "bullet0003", - "Type": 6, "Name": "", + "Type": 6, "Quality": 0, "Price": 0, "Intro": "", @@ -281,8 +281,8 @@ }, { "Id": "bullet0004", - "Type": 6, "Name": "\u69B4\u5F39\u70AE", + "Type": 6, "Quality": 0, "Price": 0, "Intro": "", @@ -295,8 +295,8 @@ }, { "Id": "bullet0005", - "Type": 6, "Name": "\u629B\u7269\u7EBF\u7C98\u6DB2\u5B50\u5F39", + "Type": 6, "Quality": 0, "Price": 0, "Intro": "", @@ -309,8 +309,8 @@ }, { "Id": "bullet0006", - "Type": 6, "Name": "\u62D6\u5C3E\u5B50\u5F39", + "Type": 6, "Quality": 0, "Price": 0, "Intro": "", @@ -323,8 +323,8 @@ }, { "Id": "bullet0007", - "Type": 6, "Name": "", + "Type": 6, "Quality": 0, "Price": 0, "Intro": "", @@ -337,8 +337,8 @@ }, { "Id": "bullet0008", - "Type": 6, "Name": "", + "Type": 6, "Quality": 0, "Price": 0, "Intro": "", @@ -351,8 +351,8 @@ }, { "Id": "bullet0009", - "Type": 6, "Name": "\u5F13\u7BAD", + "Type": 6, "Quality": 0, "Price": 0, "Intro": "", @@ -365,8 +365,8 @@ }, { "Id": "shell0001", - "Type": 7, "Name": "", + "Type": 7, "Quality": 0, "Price": 0, "Intro": "", @@ -379,8 +379,8 @@ }, { "Id": "shell0002", - "Type": 7, "Name": "", + "Type": 7, "Quality": 0, "Price": 0, "Intro": "", @@ -393,8 +393,8 @@ }, { "Id": "shell0003", - "Type": 7, "Name": "", + "Type": 7, "Quality": 0, "Price": 0, "Intro": "", @@ -407,8 +407,8 @@ }, { "Id": "shell0004", - "Type": 7, "Name": "", + "Type": 7, "Quality": 0, "Price": 0, "Intro": "", @@ -421,8 +421,8 @@ }, { "Id": "enemy_dead0001", - "Type": 8, "Name": "", + "Type": 8, "Quality": 0, "Price": 0, "Intro": "\u654C\u4EBA1\u6B7B\u4EA1\u788E\u7247", @@ -435,8 +435,8 @@ }, { "Id": "enemy_dead0002", - "Type": 8, "Name": "", + "Type": 8, "Quality": 0, "Price": 0, "Intro": "\u654C\u4EBA2\u6B7B\u4EA1", @@ -449,22 +449,22 @@ }, { "Id": "prop0001", - "Type": 9, "Name": "\u978B\u5B50", + "Type": 9, "Quality": 4, "Price": 0, "Intro": "\u63D0\u9AD8\u79FB\u52A8\u901F\u5EA6", - "Details": "", + "Details": "\u63D0\u9AD8\u89D2\u8272\u7684\u57FA\u7840\u79FB\u52A8\u901F\u5EA6", "IsStatic": false, "__Material": "", - "Prefab": "res://prefab/prop/buff/BuffProp0001.tscn", + "Prefab": "res://prefab/prop/BuffActivity.tscn", "Icon": "res://resource/sprite/prop/buff/BuffProp0001.png", "ShowInMapEditor": true }, { "Id": "prop0002", - "Type": 9, "Name": "\u5FC3\u4E4B\u5BB9\u5668", + "Type": 9, "Quality": 3, "Price": 0, "Intro": "\u63D0\u9AD8\u8840\u91CF\u4E0A\u9650", @@ -477,8 +477,8 @@ }, { "Id": "prop0003", - "Type": 9, "Name": "\u62A4\u76FE", + "Type": 9, "Quality": 3, "Price": 0, "Intro": "\u53EF\u4EE5\u62B5\u6321\u5B50\u5F39\uFF0C\u968F\u65F6\u95F4\u63A8\u79FB\u81EA\u52A8\u6062\u590D", @@ -491,8 +491,8 @@ }, { "Id": "prop0004", - "Type": 9, "Name": "\u62A4\u76FE\u8BA1\u65F6\u5668", + "Type": 9, "Quality": 4, "Price": 0, "Intro": "\u63D0\u9AD8\u62A4\u76FE\u6062\u590D\u901F\u5EA6", @@ -505,8 +505,8 @@ }, { "Id": "prop0005", - "Type": 9, "Name": "\u6740\u4F24\u5F39", + "Type": 9, "Quality": 4, "Price": 0, "Intro": "\u63D0\u9AD8\u5B50\u5F39\u4F24\u5BB3", @@ -519,8 +519,8 @@ }, { "Id": "prop0006", - "Type": 9, "Name": "\u7EA2\u5B9D\u77F3\u6212\u6307", + "Type": 9, "Quality": 4, "Price": 0, "Intro": "\u53D7\u4F24\u540E\u5EF6\u957F\u65E0\u654C\u65F6\u95F4", @@ -533,8 +533,8 @@ }, { "Id": "prop0007", - "Type": 9, "Name": "\u5907\u7528\u62A4\u76FE", + "Type": 9, "Quality": 3, "Price": 0, "Intro": "\u53D7\u4F24\u65F6\u6709\u4E00\u5B9A\u6982\u7387\u62B5\u6D88\u4F24\u5BB3", @@ -547,8 +547,8 @@ }, { "Id": "prop0008", - "Type": 9, "Name": "\u773C\u955C", + "Type": 9, "Quality": 3, "Price": 0, "Intro": "\u63D0\u9AD8\u6B66\u5668\u7CBE\u51C6\u5EA6", @@ -561,8 +561,8 @@ }, { "Id": "prop0009", - "Type": 9, "Name": "\u9AD8\u901F\u5B50\u5F39", + "Type": 9, "Quality": 3, "Price": 0, "Intro": "\u63D0\u9AD8\u5B50\u5F39\u901F\u5EA6\u548C\u5C04\u7A0B", @@ -575,8 +575,8 @@ }, { "Id": "prop0010", - "Type": 9, "Name": "\u5206\u88C2\u5B50\u5F39", + "Type": 9, "Quality": 4, "Price": 0, "Intro": "\u5B50\u5F39\u6570\u91CF\u7FFB\u500D, \u4F46\u662F\u7CBE\u51C6\u5EA6, \u51FB\u9000\u548C\u4F24\u5BB3\u964D\u4F4E", @@ -589,8 +589,8 @@ }, { "Id": "prop0011", - "Type": 9, "Name": "\u5F39\u5C04\u5B50\u5F39", + "Type": 9, "Quality": 4, "Price": 0, "Intro": "\u5B50\u5F39\u53CD\u5F39\u6B21\u6570\u002B2", @@ -603,8 +603,8 @@ }, { "Id": "prop0012", - "Type": 9, "Name": "\u7A7F\u900F\u5B50\u5F39", + "Type": 9, "Quality": 4, "Price": 0, "Intro": "\u5B50\u5F39\u7A7F\u900F\u002B1", @@ -617,8 +617,8 @@ }, { "Id": "prop0013", - "Type": 9, "Name": "\u6B66\u5668\u80CC\u5305", + "Type": 9, "Quality": 2, "Price": 0, "Intro": "\u6B66\u5668\u5BB9\u91CF\u002B1", @@ -631,8 +631,8 @@ }, { "Id": "prop0014", - "Type": 9, "Name": "\u9053\u5177\u80CC\u5305", + "Type": 9, "Quality": 2, "Price": 0, "Intro": "\u9053\u5177\u5BB9\u91CF\u002B1", @@ -645,8 +645,8 @@ }, { "Id": "prop5000", - "Type": 9, "Name": "\u533B\u836F\u7BB1", + "Type": 9, "Quality": 1, "Price": 0, "Intro": "\u4F7F\u7528\u540E\u56DE\u590D\u4E00\u9897\u7EA2\u5FC3", @@ -659,8 +659,8 @@ }, { "Id": "prop5001", - "Type": 9, "Name": "\u5F39\u836F\u7BB1", + "Type": 9, "Quality": 1, "Price": 0, "Intro": "\u4F7F\u7528\u540E\u8865\u5145\u5F53\u524D\u6B66\u5668\u5907\u7528\u5F39\u836F", @@ -673,8 +673,8 @@ }, { "Id": "treasure_box0001", - "Type": 10, "Name": "\u6728\u8D28\u5B9D\u7BB1", + "Type": 10, "Quality": 0, "Price": 0, "Intro": "\u6728\u8D28\u5B9D\u7BB1", @@ -687,8 +687,8 @@ }, { "Id": "other_door_e", - "Type": 99, "Name": "", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "\u5730\u7262\u623F\u95F4\u7684\u95E8(\u4E1C\u4FA7)", @@ -701,8 +701,8 @@ }, { "Id": "other_door_w", - "Type": 99, "Name": "", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "\u5730\u7262\u623F\u95F4\u7684\u95E8(\u897F\u4FA7)", @@ -715,8 +715,8 @@ }, { "Id": "other_door_s", - "Type": 99, "Name": "", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "\u5730\u7262\u623F\u95F4\u7684\u95E8(\u5357\u4FA7)", @@ -729,8 +729,8 @@ }, { "Id": "other_door_n", - "Type": 99, "Name": "", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "\u5730\u7262\u623F\u95F4\u7684\u95E8(\u5317\u4FA7)", @@ -743,8 +743,8 @@ }, { "Id": "gold_10", - "Type": 99, "Name": "\u91D1\u5E01", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "\u83B7\u5F9710\u91D1\u5E01", @@ -757,8 +757,8 @@ }, { "Id": "gold_5", - "Type": 99, "Name": "\u94F6\u5E01", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "\u83B7\u5F975\u91D1\u5E01", @@ -771,8 +771,8 @@ }, { "Id": "gold_1", - "Type": 99, "Name": "\u94DC\u5E01", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "\u83B7\u5F971\u91D1\u5E01", @@ -785,8 +785,8 @@ }, { "Id": "item_0001", - "Type": 99, "Name": "\u7535\u8111\u684C", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -799,8 +799,8 @@ }, { "Id": "item_0002", - "Type": 99, "Name": "", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -813,8 +813,8 @@ }, { "Id": "item_0003", - "Type": 99, "Name": "", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -827,8 +827,8 @@ }, { "Id": "item_0004", - "Type": 99, "Name": "", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -841,8 +841,8 @@ }, { "Id": "item_0005", - "Type": 99, "Name": "", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -855,8 +855,8 @@ }, { "Id": "item_0006", - "Type": 99, "Name": "\u7535\u89C6\u684C", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -869,8 +869,8 @@ }, { "Id": "item_0007", - "Type": 99, "Name": "\u9152\u67DC", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -883,8 +883,8 @@ }, { "Id": "item_0008", - "Type": 99, "Name": "\u6C99\u53D1\u65C1\u67DC\u5B50", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -897,8 +897,8 @@ }, { "Id": "item_0009", - "Type": 99, "Name": "\u5427\u53F0", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -911,8 +911,8 @@ }, { "Id": "item_0010", - "Type": 99, "Name": "\u544A\u793A\u724C", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -925,8 +925,8 @@ }, { "Id": "item_0011", - "Type": 99, "Name": "\u7EFF\u6728\u51F3", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -939,8 +939,8 @@ }, { "Id": "item_0012", - "Type": 99, "Name": "\u6C99\u53D1\u7AD6", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -953,8 +953,8 @@ }, { "Id": "item_0013", - "Type": 99, "Name": "\u6C99\u53D1\u6A2A\u7740", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -967,8 +967,8 @@ }, { "Id": "item_0014", - "Type": 99, "Name": "\u61D2\u4EBA\u6C99\u53D1", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -981,8 +981,8 @@ }, { "Id": "item_0015", - "Type": 99, "Name": "\u5DE6\u4E0B\u89D2\u684C\u5B50", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -995,8 +995,8 @@ }, { "Id": "item_0016", - "Type": 99, "Name": "\u5DE6\u4E0B\u89D2\u77ED\u6C99\u53D1", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1009,8 +1009,8 @@ }, { "Id": "item_0017", - "Type": 99, "Name": "\u4E2D\u95F4\u684C\u5B50", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1023,8 +1023,8 @@ }, { "Id": "item_0018", - "Type": 99, "Name": "\u5DE6\u4E0B\u89D2\u957F\u6C99\u53D1", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1037,8 +1037,8 @@ }, { "Id": "item_0019", - "Type": 99, "Name": "\u53F3\u4E0B\u89D2\u684C\u5B50", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1051,8 +1051,8 @@ }, { "Id": "item_0020", - "Type": 99, "Name": "\u8F6C\u6905", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1065,8 +1065,8 @@ }, { "Id": "item_0021", - "Type": 99, "Name": "\u53F3\u4E0B\u89D2\u957F\u6C99\u53D1", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1079,8 +1079,8 @@ }, { "Id": "item_0022", - "Type": 99, "Name": "\u8863\u67B6", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1093,8 +1093,8 @@ }, { "Id": "item_0023", - "Type": 99, "Name": "\u7EFF\u690D", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1107,8 +1107,8 @@ }, { "Id": "item_0024", - "Type": 99, "Name": "\u65B0\u624B\u6559\u5B66\u5173\u5361", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1121,8 +1121,8 @@ }, { "Id": "item_0025", - "Type": 99, "Name": "\u8302\u76DB\u82B1\u76C6", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1135,8 +1135,8 @@ }, { "Id": "item_0026", - "Type": 99, "Name": "\u544A\u793A\u7248", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1149,8 +1149,8 @@ }, { "Id": "item_0031", - "Type": 99, "Name": "\u53F0\u706F", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1163,8 +1163,8 @@ }, { "Id": "item_0033", - "Type": 99, "Name": "\u5427\u53F0", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1177,8 +1177,8 @@ }, { "Id": "item_0036", - "Type": 99, "Name": "\u53F0\u7403\u684C", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1191,8 +1191,8 @@ }, { "Id": "item_0054", - "Type": 99, "Name": "\u8D29\u5356\u673A", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1205,8 +1205,8 @@ }, { "Id": "item_0056", - "Type": 99, "Name": "\u957F\u51F3\u5B50", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", @@ -1219,8 +1219,8 @@ }, { "Id": "item_0057", - "Type": 99, "Name": "\u5361\u5E26\u76D2\u5B50", + "Type": 99, "Quality": 0, "Price": 0, "Intro": "", diff --git a/DungeonShooting_Godot/resource/config/BuffBase.json b/DungeonShooting_Godot/resource/config/BuffBase.json new file mode 100644 index 0000000..f0b8938 --- /dev/null +++ b/DungeonShooting_Godot/resource/config/BuffBase.json @@ -0,0 +1,37 @@ +[ + { + "Id": "0001", + "Remark": "\u978B\u5B50", + "__Activity": "prop0001", + "IsActivity": false, + "Buff": { + "MoveSpeed": [ + 30 + ] + } + }, + { + "Id": "0010", + "Remark": "\u5206\u88C2\u5B50\u5F39", + "__Activity": "prop0010", + "IsActivity": false, + "Buff": { + "BulletCount": [ + 2, + 1 + ], + "BulletDeviationAngle": [ + -8, + 8 + ], + "Damage": [ + 2, + -0.35 + ], + "BulletRepel": [ + 2, + -0.35 + ] + } + } +] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json index 30bf56e..092a429 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json @@ -1 +1 @@ -[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":false,"WaveList":[[{"Position":{"X":39,"Y":8},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":-16,"Y":-18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":6},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0009","Weight":100,"Attr":{"CurrAmmon":"1","ResidueAmmo":"25"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0010","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":47,"Y":-32},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0008","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":23,"Y":37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0010","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0005","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":24,"Y":-30},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0006","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":40,"Y":-10},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0003","Weight":100,"Attr":{"CurrAmmon":"12","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":-37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0007","Weight":100,"Attr":{"CurrAmmon":"60","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-2,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0002","Weight":100,"Attr":{"CurrAmmon":"7","ResidueAmmo":"70"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":29,"Y":63},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0013","Weight":100,"Attr":{"CurrAmmon":"50","ResidueAmmo":"250"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-30,"Y":39},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-19,"Y":71},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":48,"Y":29},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0004","Weight":100,"Attr":{"CurrAmmon":"180","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":20,"Y":94},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0014","Weight":100,"Attr":{"CurrAmmon":"5","ResidueAmmo":"60"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-14,"Y":97},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0011","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":9,"Y":-7},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0011","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-41,"Y":61},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0016","Weight":100,"Attr":{"CurrAmmon":"5","ResidueAmmo":"60"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":73,"Y":-19},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0005","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"40"},"Altitude":8,"VerticalSpeed":5.551115E-14}]}]]}] \ No newline at end of file +[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":false,"WaveList":[[{"Position":{"X":39,"Y":8},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":-16,"Y":-18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":6},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0009","Weight":100,"Attr":{"CurrAmmon":"1","ResidueAmmo":"25"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0010","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":47,"Y":-32},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0008","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":23,"Y":37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0010","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0005","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":24,"Y":-30},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0006","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":40,"Y":-10},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0003","Weight":100,"Attr":{"CurrAmmon":"12","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":-37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0007","Weight":100,"Attr":{"CurrAmmon":"60","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-2,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0002","Weight":100,"Attr":{"CurrAmmon":"7","ResidueAmmo":"70"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":29,"Y":63},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0013","Weight":100,"Attr":{"CurrAmmon":"50","ResidueAmmo":"250"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-30,"Y":39},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-19,"Y":71},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":48,"Y":29},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0004","Weight":100,"Attr":{"CurrAmmon":"180","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":20,"Y":94},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0014","Weight":100,"Attr":{"CurrAmmon":"5","ResidueAmmo":"60"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-14,"Y":97},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0011","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":9,"Y":-7},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0011","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-41,"Y":61},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0016","Weight":100,"Attr":{"CurrAmmon":"5","ResidueAmmo":"60"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":73,"Y":-19},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0005","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"40"},"Altitude":8,"VerticalSpeed":5.551115E-14}]},{"Position":{"X":-72,"Y":71},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0001","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":5.551115E-14}]}]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/src/config/ExcelConfig.cs b/DungeonShooting_Godot/src/config/ExcelConfig.cs index 0f3fe56..8670373 100644 --- a/DungeonShooting_Godot/src/config/ExcelConfig.cs +++ b/DungeonShooting_Godot/src/config/ExcelConfig.cs @@ -8,13 +8,22 @@ public static partial class ExcelConfig { /// - /// ActivityBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 + /// Sound.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 /// - public static List ActivityBase_List { get; private set; } + public static List Sound_List { get; private set; } /// - /// ActivityBase.xlsx表数据集合, 里 Map 形式存储, key 为 Id + /// Sound.xlsx表数据集合, 里 Map 形式存储, key 为 Id /// - public static Dictionary ActivityBase_Map { get; private set; } + public static Dictionary Sound_Map { get; private set; } + + /// + /// WeaponBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 + /// + public static List WeaponBase_List { get; private set; } + /// + /// WeaponBase.xlsx表数据集合, 里 Map 形式存储, key 为 Id + /// + public static Dictionary WeaponBase_Map { get; private set; } /// /// ActivityMaterial.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 @@ -35,6 +44,15 @@ public static Dictionary AiAttackAttr_Map { get; private set; } /// + /// BuffBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 + /// + public static List BuffBase_List { get; private set; } + /// + /// BuffBase.xlsx表数据集合, 里 Map 形式存储, key 为 Id + /// + public static Dictionary BuffBase_Map { get; private set; } + + /// /// BulletBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 /// public static List BulletBase_List { get; private set; } @@ -53,6 +71,15 @@ public static Dictionary EnemyBase_Map { get; private set; } /// + /// ActivityBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 + /// + public static List ActivityBase_List { get; private set; } + /// + /// ActivityBase.xlsx表数据集合, 里 Map 形式存储, key 为 Id + /// + public static Dictionary ActivityBase_Map { get; private set; } + + /// /// LiquidMaterial.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 /// public static List LiquidMaterial_List { get; private set; } @@ -61,24 +88,6 @@ /// public static Dictionary LiquidMaterial_Map { get; private set; } - /// - /// Sound.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 - /// - public static List Sound_List { get; private set; } - /// - /// Sound.xlsx表数据集合, 里 Map 形式存储, key 为 Id - /// - public static Dictionary Sound_Map { get; private set; } - - /// - /// WeaponBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 - /// - public static List WeaponBase_List { get; private set; } - /// - /// WeaponBase.xlsx表数据集合, 里 Map 形式存储, key 为 Id - /// - public static Dictionary WeaponBase_Map { get; private set; } - private static bool _init = false; /// @@ -89,35 +98,55 @@ if (_init) return; _init = true; - _InitActivityBaseConfig(); - _InitActivityMaterialConfig(); - _InitAiAttackAttrConfig(); - _InitBulletBaseConfig(); - _InitEnemyBaseConfig(); - _InitLiquidMaterialConfig(); _InitSoundConfig(); _InitWeaponBaseConfig(); + _InitActivityMaterialConfig(); + _InitAiAttackAttrConfig(); + _InitBuffBaseConfig(); + _InitBulletBaseConfig(); + _InitEnemyBaseConfig(); + _InitActivityBaseConfig(); + _InitLiquidMaterialConfig(); - _InitActivityBaseRef(); - _InitEnemyBaseRef(); _InitWeaponBaseRef(); + _InitBuffBaseRef(); + _InitEnemyBaseRef(); + _InitActivityBaseRef(); } - private static void _InitActivityBaseConfig() + private static void _InitSoundConfig() { try { - var text = _ReadConfigAsText("res://resource/config/ActivityBase.json"); - ActivityBase_List = new List(JsonSerializer.Deserialize>(text)); - ActivityBase_Map = new Dictionary(); - foreach (var item in ActivityBase_List) + var text = _ReadConfigAsText("res://resource/config/Sound.json"); + Sound_List = JsonSerializer.Deserialize>(text); + Sound_Map = new Dictionary(); + foreach (var item in Sound_List) { - ActivityBase_Map.Add(item.Id, item); + Sound_Map.Add(item.Id, item); } } catch (Exception e) { GD.PrintErr(e.ToString()); - throw new Exception("初始化表'ActivityBase'失败!"); + throw new Exception("初始化表'Sound'失败!"); + } + } + private static void _InitWeaponBaseConfig() + { + try + { + var text = _ReadConfigAsText("res://resource/config/WeaponBase.json"); + WeaponBase_List = new List(JsonSerializer.Deserialize>(text)); + WeaponBase_Map = new Dictionary(); + foreach (var item in WeaponBase_List) + { + WeaponBase_Map.Add(item.Id, item); + } + } + catch (Exception e) + { + GD.PrintErr(e.ToString()); + throw new Exception("初始化表'WeaponBase'失败!"); } } private static void _InitActivityMaterialConfig() @@ -156,6 +185,24 @@ throw new Exception("初始化表'AiAttackAttr'失败!"); } } + private static void _InitBuffBaseConfig() + { + try + { + var text = _ReadConfigAsText("res://resource/config/BuffBase.json"); + BuffBase_List = new List(JsonSerializer.Deserialize>(text)); + BuffBase_Map = new Dictionary(); + foreach (var item in BuffBase_List) + { + BuffBase_Map.Add(item.Id, item); + } + } + catch (Exception e) + { + GD.PrintErr(e.ToString()); + throw new Exception("初始化表'BuffBase'失败!"); + } + } private static void _InitBulletBaseConfig() { try @@ -192,6 +239,24 @@ throw new Exception("初始化表'EnemyBase'失败!"); } } + private static void _InitActivityBaseConfig() + { + try + { + var text = _ReadConfigAsText("res://resource/config/ActivityBase.json"); + ActivityBase_List = new List(JsonSerializer.Deserialize>(text)); + ActivityBase_Map = new Dictionary(); + foreach (var item in ActivityBase_List) + { + ActivityBase_Map.Add(item.Id, item); + } + } + catch (Exception e) + { + GD.PrintErr(e.ToString()); + throw new Exception("初始化表'ActivityBase'失败!"); + } + } private static void _InitLiquidMaterialConfig() { try @@ -210,81 +275,7 @@ throw new Exception("初始化表'LiquidMaterial'失败!"); } } - private static void _InitSoundConfig() - { - try - { - var text = _ReadConfigAsText("res://resource/config/Sound.json"); - Sound_List = JsonSerializer.Deserialize>(text); - Sound_Map = new Dictionary(); - foreach (var item in Sound_List) - { - Sound_Map.Add(item.Id, item); - } - } - catch (Exception e) - { - GD.PrintErr(e.ToString()); - throw new Exception("初始化表'Sound'失败!"); - } - } - private static void _InitWeaponBaseConfig() - { - try - { - var text = _ReadConfigAsText("res://resource/config/WeaponBase.json"); - WeaponBase_List = new List(JsonSerializer.Deserialize>(text)); - WeaponBase_Map = new Dictionary(); - foreach (var item in WeaponBase_List) - { - WeaponBase_Map.Add(item.Id, item); - } - } - catch (Exception e) - { - GD.PrintErr(e.ToString()); - throw new Exception("初始化表'WeaponBase'失败!"); - } - } - private static void _InitActivityBaseRef() - { - foreach (Ref_ActivityBase item in ActivityBase_List) - { - try - { - if (!string.IsNullOrEmpty(item.__Material)) - { - item.Material = ActivityMaterial_Map[item.__Material]; - } - - } - catch (Exception e) - { - GD.PrintErr(e.ToString()); - throw new Exception("初始化'ActivityBase'引用其他表数据失败, 当前行id: " + item.Id); - } - } - } - private static void _InitEnemyBaseRef() - { - foreach (Ref_EnemyBase item in EnemyBase_List) - { - try - { - if (!string.IsNullOrEmpty(item.__Activity)) - { - item.Activity = ActivityBase_Map[item.__Activity]; - } - - } - catch (Exception e) - { - GD.PrintErr(e.ToString()); - throw new Exception("初始化'EnemyBase'引用其他表数据失败, 当前行id: " + item.Id); - } - } - } private static void _InitWeaponBaseRef() { foreach (Ref_WeaponBase item in WeaponBase_List) @@ -353,6 +344,63 @@ } } } + private static void _InitBuffBaseRef() + { + foreach (Ref_BuffBase item in BuffBase_List) + { + try + { + if (!string.IsNullOrEmpty(item.__Activity)) + { + item.Activity = ActivityBase_Map[item.__Activity]; + } + + } + catch (Exception e) + { + GD.PrintErr(e.ToString()); + throw new Exception("初始化'BuffBase'引用其他表数据失败, 当前行id: " + item.Id); + } + } + } + private static void _InitEnemyBaseRef() + { + foreach (Ref_EnemyBase item in EnemyBase_List) + { + try + { + if (!string.IsNullOrEmpty(item.__Activity)) + { + item.Activity = ActivityBase_Map[item.__Activity]; + } + + } + catch (Exception e) + { + GD.PrintErr(e.ToString()); + throw new Exception("初始化'EnemyBase'引用其他表数据失败, 当前行id: " + item.Id); + } + } + } + private static void _InitActivityBaseRef() + { + foreach (Ref_ActivityBase item in ActivityBase_List) + { + try + { + if (!string.IsNullOrEmpty(item.__Material)) + { + item.Material = ActivityMaterial_Map[item.__Material]; + } + + } + catch (Exception e) + { + GD.PrintErr(e.ToString()); + throw new Exception("初始化'ActivityBase'引用其他表数据失败, 当前行id: " + item.Id); + } + } + } private static string _ReadConfigAsText(string path) { var file = FileAccess.Open(path, FileAccess.ModeFlags.Read); diff --git a/DungeonShooting_Godot/src/config/ExcelConfig_ActivityBase.cs b/DungeonShooting_Godot/src/config/ExcelConfig_ActivityBase.cs index d19cfa0..3e86482 100644 --- a/DungeonShooting_Godot/src/config/ExcelConfig_ActivityBase.cs +++ b/DungeonShooting_Godot/src/config/ExcelConfig_ActivityBase.cs @@ -15,6 +15,12 @@ public string Id; /// + /// 物体名称 + /// + [JsonInclude] + public string Name; + + /// /// Test(测试对象): 2
/// Role(角色): 3
/// Enemy(敌人): 4
@@ -30,12 +36,6 @@ public ActivityType Type; /// - /// 物体名称 - /// - [JsonInclude] - public string Name; - - /// /// 物体品质, 用于武器和道具
/// 通用物品: 1
/// 基础: 2
@@ -106,8 +106,8 @@ { var inst = new ActivityBase(); inst.Id = Id; - inst.Type = Type; inst.Name = Name; + inst.Type = Type; inst.Quality = Quality; inst.Price = Price; inst.Intro = Intro; diff --git a/DungeonShooting_Godot/src/config/ExcelConfig_BuffBase.cs b/DungeonShooting_Godot/src/config/ExcelConfig_BuffBase.cs new file mode 100644 index 0000000..844d210 --- /dev/null +++ b/DungeonShooting_Godot/src/config/ExcelConfig_BuffBase.cs @@ -0,0 +1,62 @@ +using System.Text.Json.Serialization; +using System.Collections.Generic; + +namespace Config; + +public static partial class ExcelConfig +{ + public class BuffBase + { + /// + /// Buff Id + /// + [JsonInclude] + public string Id; + + /// + /// 备注 + /// + [JsonInclude] + public string Remark; + + /// + /// 属性绑定Buff实体的Id,这个id时ActivityBase表Id + /// + public ActivityBase Activity; + + /// + /// 是否是主动道具, 默认false + /// + [JsonInclude] + public bool IsActivity; + + /// + /// 被动Buff效果
+ /// 也就是当前buff道具所有挂载的被动属性集合, 具体属性名称请参阅buff属性表
+ /// key为buff属性名称
+ /// value为buff初始化参数 + ///
+ [JsonInclude] + public Dictionary Buff; + + /// + /// 返回浅拷贝出的新对象 + /// + public BuffBase Clone() + { + var inst = new BuffBase(); + inst.Id = Id; + inst.Remark = Remark; + inst.Activity = Activity; + inst.IsActivity = IsActivity; + inst.Buff = Buff; + return inst; + } + } + private class Ref_BuffBase : BuffBase + { + [JsonInclude] + public string __Activity; + + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index 5670489..3121c92 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -91,6 +91,7 @@ //初始化配置表 ExcelConfig.Init(); PreinstallMarkManager.Init(); + BuffRegister.Init(); //初始化房间配置数据 InitRoomConfig(); //初始化TileSet配置数据 @@ -99,6 +100,8 @@ Weapon.InitWeaponAttribute(); //初始化敌人数据 Enemy.InitEnemyAttribute(); + //初始化buff数据 + BuffActivity.InitBuffAttribute(); DungeonConfig = new DungeonConfig(); DungeonConfig.GroupName = "Test1"; diff --git a/DungeonShooting_Godot/src/game/activity/prop/BuffActivity.cs b/DungeonShooting_Godot/src/game/activity/prop/BuffActivity.cs index 9b5dbfe..4fbe2e7 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/BuffActivity.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/BuffActivity.cs @@ -1,5 +1,7 @@  +using System; using System.Collections.Generic; +using Config; using Godot; /// @@ -10,7 +12,64 @@ { //被动属性 private readonly List _buffFragment = new List(); - + + public override void OnInit() + { + base.OnInit(); + var buffAttribute = GetBuffAttribute(ActivityBase.Id); + if (buffAttribute != null) + { + //初始化buff属性 + foreach (var keyValuePair in buffAttribute.Buff) + { + var buffInfo = BuffRegister.BuffInfos[keyValuePair.Key]; + var item = keyValuePair.Value; + switch (item.Length) + { + case 0: + { + var buff = (BuffFragment)AddComponent(buffInfo.Type); + _buffFragment.Add(buff); + } + break; + case 1: + { + var buff = (BuffFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0]); + _buffFragment.Add(buff); + } + break; + case 2: + { + var buff = (BuffFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0], item[1]); + _buffFragment.Add(buff); + } + break; + case 3: + { + var buff = (BuffFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0], item[1], item[2]); + _buffFragment.Add(buff); + } + break; + case 4: + { + var buff = (BuffFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0], item[1], item[2], item[3]); + _buffFragment.Add(buff); + } + break; + } + } + //显示纹理 + if (!string.IsNullOrEmpty(ActivityBase.Icon)) + { + SetDefaultTexture(ResourceManager.LoadTexture2D(ActivityBase.Icon)); + } + } + } + public override void OnPickUpItem() { foreach (var buffFragment in _buffFragment) @@ -113,4 +172,50 @@ } return base.CheckInteractive(master); } + + + private static bool _init = false; + private static Dictionary _buffAttributeMap = + new Dictionary(); + + /// + /// 初始化 buff 属性数据 + /// + public static void InitBuffAttribute() + { + if (_init) + { + return; + } + + _init = true; + foreach (var buffAttr in ExcelConfig.BuffBase_List) + { + if (buffAttr.Activity != null) + { + if (!_buffAttributeMap.TryAdd(buffAttr.Activity.Id, buffAttr)) + { + Debug.LogError("发现重复注册的 buff 属性: " + buffAttr.Id); + } + } + } + } + + /// + /// 根据 ActivityBase.Id 获取对应 buff 的属性数据 + /// + public static ExcelConfig.BuffBase GetBuffAttribute(string itemId) + { + if (itemId == null) + { + return null; + } + if (_buffAttributeMap.TryGetValue(itemId, out var attr)) + { + return attr; + } + + return null; + //throw new Exception($"buff'{itemId}'没有在 BuffBase 表中配置属性数据!"); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletCount.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletCount.cs index 73ba367..3e3174c 100644 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletCount.cs +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletCount.cs @@ -1,26 +1,49 @@ -[Buff("BulletCount", "子弹数量 buff, 参数‘1’为增加子弹的数量")] +using Godot; + +[Buff("BulletCount", "子弹数量 buff, 参数‘1’为子弹数量添加类型, 1: 具体数量, 2:百分比(小数), 参数‘2’为增加子弹的数量")] public class Buff_BulletCount : BuffFragment { - private int _value; + private int _type; + private float _value; - public override void InitParam(float arg1) + public override void InitParam(float arg1, float arg2) { + _type = (int)arg2; _value = (int)arg1; } public override void OnPickUpItem() { - Role.RoleState.CalcBulletCountEvent += CalcBulletCountEvent; + if (_type == 1) + { + Role.RoleState.CalcBulletCountEvent += CalcBulletCountEvent1; + } + else + { + Role.RoleState.CalcBulletCountEvent += CalcBulletCountEvent2; + } } public override void OnRemoveItem() { - Role.RoleState.CalcBulletCountEvent -= CalcBulletCountEvent; + if (_type == 1) + { + Role.RoleState.CalcBulletCountEvent -= CalcBulletCountEvent1; + } + else + { + Role.RoleState.CalcBulletCountEvent -= CalcBulletCountEvent2; + } } - private void CalcBulletCountEvent(int originCount, RefValue refValue) + private void CalcBulletCountEvent1(int originCount, RefValue refValue) { - refValue.Value += _value; + refValue.Value += Mathf.CeilToInt(_value); + } + + private void CalcBulletCountEvent2(int originCount, RefValue refValue) + { + refValue.Value += Mathf.CeilToInt(originCount * _value); } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletRepel.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletRepel.cs index 138b46a..ec73c52 100644 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletRepel.cs +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletRepel.cs @@ -1,4 +1,6 @@ +using Godot; + [Buff("BulletRepel", "子弹击退 buff, 参数‘1’为击退增加类型: 1:具体击退值, 2:百分比击退值(小数), 参数‘2’为子弹增加的击退值")] public class Buff_BulletRepel : BuffFragment { @@ -49,6 +51,14 @@ { return; } - repel.Value += originRepel * _value; + + if (_value > 0) + { + repel.Value += originRepel * _value; + } + else + { + repel.Value = Mathf.Max(0, repel.Value - Mathf.FloorToInt(repel.Value * _value)); + } } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletSpeed.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletSpeed.cs index d2f4c43..b438e39 100644 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletSpeed.cs +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletSpeed.cs @@ -1,5 +1,8 @@ -[Buff("BulletSpeed", "子弹速度 buff, 参数‘1’为射速增加类型: 1:具体射速, 2:百分比射速(小数), 参数‘2’为子弹增加的射速值")] +[Buff("BulletSpeed", + "子弹速度 buff, " + + "参数‘1’为射速增加类型: 1:具体射速, 2:百分比射速(小数), " + + "参数‘2’为子弹增加的射速值")] public class Buff_BulletSpeed : BuffFragment { private int _type; diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_Damage.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_Damage.cs index b27008b..f12a8d2 100644 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_Damage.cs +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_Damage.cs @@ -1,7 +1,10 @@ using Godot; -[Buff("Damage", "提升伤害buff, 参数‘1’为伤害增加类型: 1:具体伤害, 2:百分比伤害(小数), 参数‘2’为增益伤害值")] +[Buff("Damage", + "提升伤害buff, " + + "参数‘1’为伤害增加类型: 1:具体伤害, 2:百分比伤害(小数), " + + "参数‘2’为增益伤害值")] public class Buff_Damage : BuffFragment { private int _type; @@ -44,6 +47,13 @@ private void CalcDamage2(int originDamage, RefValue refValue) { - refValue.Value += Mathf.CeilToInt(originDamage * _value); + if (_value > 0) + { + refValue.Value += Mathf.CeilToInt(originDamage * _value); + } + else + { + refValue.Value = Mathf.Max(1, refValue.Value - Mathf.FloorToInt(refValue.Value * _value)); + } } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_MoveSpeed.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_MoveSpeed.cs index 04c5cd8..880ef7f 100644 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_MoveSpeed.cs +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_MoveSpeed.cs @@ -13,13 +13,13 @@ { Role.RoleState.MoveSpeed += _moveSpeed; Role.RoleState.Acceleration += _moveSpeed * 1.4f; - Role.RoleState.Friction += _moveSpeed; + Role.RoleState.Friction += _moveSpeed * 10; } public override void OnRemoveItem() { Role.RoleState.MoveSpeed -= _moveSpeed; Role.RoleState.Acceleration -= _moveSpeed * 1.4f; - Role.RoleState.Friction -= _moveSpeed; + Role.RoleState.Friction -= _moveSpeed * 10; } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/data/BuffInfo.cs b/DungeonShooting_Godot/src/game/data/BuffInfo.cs new file mode 100644 index 0000000..08e185a --- /dev/null +++ b/DungeonShooting_Godot/src/game/data/BuffInfo.cs @@ -0,0 +1,45 @@ + +using System; +using System.Collections.Generic; + +/// +/// buff 属性数据 +/// +public class BuffInfo +{ + /// + /// buff 名称 + /// + public string Name; + + /// + /// buff 描述 + /// + public string Description; + + /// + /// buff 可传参数 + /// + public List Params; + + /// + /// buff 类 + /// + public Type Type; + + public BuffInfo(string name, string description, Type type) + { + Name = name; + Description = description; + Type = type; + Params = new List(); + } + + public BuffInfo(string name, string description, List paramsList, Type type) + { + Name = name; + Description = description; + Params = paramsList; + Type = type; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/manager/BuffRegister.cs b/DungeonShooting_Godot/src/game/manager/BuffRegister.cs new file mode 100644 index 0000000..2180ab3 --- /dev/null +++ b/DungeonShooting_Godot/src/game/manager/BuffRegister.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +/// +/// buff 注册类, 调用 Init() 函数初始化数据 +/// 注意: 该类为 Tools 面板下自动生成的, 请不要手动编辑! +/// +public class BuffRegister +{ + /// + /// 所有 buff 信息 + /// + public static Dictionary BuffInfos { get; private set; } + /// + /// 初始化 buff + /// + public static void Init() + { + BuffInfos = new Dictionary(); + BuffInfos.Add("ActivePropsCapacity", new BuffInfo("ActivePropsCapacity", null, new List() { 1 }, typeof(Buff_ActivePropsCapacity))); + BuffInfos.Add("BulletBounceCount", new BuffInfo("BulletBounceCount", null, new List() { 1 }, typeof(Buff_BulletBounceCount))); + BuffInfos.Add("BulletCount", new BuffInfo("BulletCount", null, new List() { 2 }, typeof(Buff_BulletCount))); + BuffInfos.Add("BulletDeviationAngle", new BuffInfo("BulletDeviationAngle", null, new List() { 2 }, typeof(Buff_BulletDeviationAngle))); + BuffInfos.Add("BulletDistance", new BuffInfo("BulletDistance", null, new List() { 2 }, typeof(Buff_BulletDistance))); + BuffInfos.Add("BulletPenetration", new BuffInfo("BulletPenetration", null, new List() { 1 }, typeof(Buff_BulletPenetration))); + BuffInfos.Add("BulletRepel", new BuffInfo("BulletRepel", null, new List() { 2 }, typeof(Buff_BulletRepel))); + BuffInfos.Add("BulletSpeed", new BuffInfo("BulletSpeed", null, new List() { 2 }, typeof(Buff_BulletSpeed))); + BuffInfos.Add("Damage", new BuffInfo("Damage", null, new List() { 2 }, typeof(Buff_Damage))); + BuffInfos.Add("MaxHp", new BuffInfo("MaxHp", null, new List() { 1 }, typeof(Buff_MaxHp))); + BuffInfos.Add("MaxShield", new BuffInfo("MaxShield", null, new List() { 1 }, typeof(Buff_MaxShield))); + BuffInfos.Add("MoveSpeed", new BuffInfo("MoveSpeed", null, new List() { 1 }, typeof(Buff_MoveSpeed))); + BuffInfos.Add("OffsetInjury", new BuffInfo("OffsetInjury", null, new List() { 1 }, typeof(Buff_OffsetInjury))); + BuffInfos.Add("Scattering", new BuffInfo("Scattering", null, new List() { 1 }, typeof(Buff_Scattering))); + BuffInfos.Add("ShieldRecoveryTime", new BuffInfo("ShieldRecoveryTime", null, new List() { 1 }, typeof(Buff_ShieldRecoveryTime))); + BuffInfos.Add("WeaponCapacity", new BuffInfo("WeaponCapacity", null, new List() { 1 }, typeof(Buff_WeaponCapacity))); + BuffInfos.Add("WoundedInvincibleTime", new BuffInfo("WoundedInvincibleTime", null, new List() { 1 }, typeof(Buff_WoundedInvincibleTime))); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/editorTools/EditorToolsPanel.cs b/DungeonShooting_Godot/src/game/ui/editorTools/EditorToolsPanel.cs index 6b7482c..600cc68 100644 --- a/DungeonShooting_Godot/src/game/ui/editorTools/EditorToolsPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/editorTools/EditorToolsPanel.cs @@ -308,23 +308,14 @@ /// private void GenerateBuffAttrTable() { - var str = ""; - var types = GetType().Assembly.GetTypes(); - //包含[BuffAttribute]特性 - var enumerable = types.Where(type => type.IsClass && !type.IsAbstract && type.IsAssignableTo(typeof(BuffFragment))); - foreach (var type in enumerable) + if (BuffGenerator.Generate()) { - var attribute = (BuffAttribute)type.GetCustomAttribute(typeof(BuffAttribute), false); - if (attribute != null) - { - //var baeMethod = typeof(BuffFragment).GetMethod(nameof(BuffFragment.InitParam), BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly, new Type[] { typeof(float) }); - //var methodInfo = type.GetMethod(nameof(BuffFragment.InitParam), BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly, new Type[] { typeof(float) }); - //str += $"{attribute.BuffName}: {methodInfo != baeMethod}, {baeMethod != null}\n"; - str += $"{attribute.BuffName}: {attribute.Description}\n"; - } + ShowTips("提示", "Buff属性表生成完成!"); } - GD.Print("-------------------------------------------"); - GD.Print(str); + else + { + ShowTips("错误", "uff属性表生成失败! 前往控制台查看错误日志!"); + } } ///