diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/BuffGenerator.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/BuffGenerator.cs index b55a29a..92ce289 100644 --- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/BuffGenerator.cs +++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/BuffGenerator.cs @@ -13,122 +13,10 @@ /// public static class BuffGenerator { - private const string SavePath = "src/game/manager/BuffRegister.cs"; - public static bool Generate() { - try - { - var str = ""; - 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); - str += $"{buffInfo.Name}: {buffInfo.Description}\n"; - 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); - GD.Print("-----------------------------"); - GD.Print(str); - } - 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/ActivePropBase.xlsx b/DungeonShooting_Godot/excel/ActivePropBase.xlsx index 260a154..57b881b 100644 --- a/DungeonShooting_Godot/excel/ActivePropBase.xlsx +++ b/DungeonShooting_Godot/excel/ActivePropBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/ActivityBase.xlsx b/DungeonShooting_Godot/excel/ActivityBase.xlsx index 22fe5c6..1053ed8 100644 --- a/DungeonShooting_Godot/excel/ActivityBase.xlsx +++ b/DungeonShooting_Godot/excel/ActivityBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/BuffPropBase.xlsx b/DungeonShooting_Godot/excel/BuffPropBase.xlsx index 66bfbee..708a012 100644 --- a/DungeonShooting_Godot/excel/BuffPropBase.xlsx +++ b/DungeonShooting_Godot/excel/BuffPropBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/prefab/prop/ActiveProp.tscn b/DungeonShooting_Godot/prefab/prop/ActiveProp.tscn new file mode 100644 index 0000000..aa0946a --- /dev/null +++ b/DungeonShooting_Godot/prefab/prop/ActiveProp.tscn @@ -0,0 +1,48 @@ +[gd_scene load_steps=6 format=3 uid="uid://drjkrimgii1u0"] + +[ext_resource type="Script" path="res://src/game/activity/prop/ActiveProp.cs" id="1_n541c"] +[ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_75di4"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_mrkt4"] +resource_local_to_scene = true +shader = ExtResource("2_75di4") +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_75di4") +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="RectangleShape2D" id="RectangleShape2D_cpqup"] +size = Vector2(12, 10) + +[node name="ActiveProp" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")] +collision_layer = 4 +script = ExtResource("1_n541c") +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") + +[node name="Collision" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_cpqup") diff --git a/DungeonShooting_Godot/prefab/prop/BuffProp.tscn b/DungeonShooting_Godot/prefab/prop/BuffProp.tscn index 34aa0c4..331309b 100644 --- a/DungeonShooting_Godot/prefab/prop/BuffProp.tscn +++ b/DungeonShooting_Godot/prefab/prop/BuffProp.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://dfpic4nubu7cf"] +[gd_scene load_steps=6 format=3 uid="uid://dfpic4nubu7cf"] [ext_resource type="Script" path="res://src/game/activity/prop/BuffProp.cs" id="1_nlcp6"] [ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_imicp"] @@ -27,9 +27,6 @@ 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) @@ -46,7 +43,6 @@ [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/prefab/prop/active/ActiveProp5000.tscn b/DungeonShooting_Godot/prefab/prop/active/ActiveProp5000.tscn deleted file mode 100644 index 26f1741..0000000 --- a/DungeonShooting_Godot/prefab/prop/active/ActiveProp5000.tscn +++ /dev/null @@ -1,50 +0,0 @@ -[gd_scene load_steps=7 format=3 uid="uid://crwflnrd6so2i"] - -[ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="1_f18nu"] -[ext_resource type="Script" path="res://src/game/activity/prop/active/ActiveProp5000.cs" id="1_nkhdg"] -[ext_resource type="SpriteFrames" uid="uid://cvosq47nbdnus" path="res://resource/spriteFrames/prop/active/ActiveProp5000.tres" id="3_4xrrj"] - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_mrkt4"] -resource_local_to_scene = true -shader = ExtResource("1_f18nu") -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("1_f18nu") -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="RectangleShape2D" id="RectangleShape2D_cpqup"] -size = Vector2(12, 10) - -[node name="ActiveProp5000" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")] -collision_layer = 4 -script = ExtResource("1_nkhdg") -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 = ExtResource("3_4xrrj") - -[node name="Collision" type="CollisionShape2D" parent="."] -shape = SubResource("RectangleShape2D_cpqup") diff --git a/DungeonShooting_Godot/prefab/prop/active/ActiveProp5001.tscn b/DungeonShooting_Godot/prefab/prop/active/ActiveProp5001.tscn deleted file mode 100644 index 7bc2069..0000000 --- a/DungeonShooting_Godot/prefab/prop/active/ActiveProp5001.tscn +++ /dev/null @@ -1,50 +0,0 @@ -[gd_scene load_steps=7 format=3 uid="uid://dlf83ph0msl2l"] - -[ext_resource type="Script" path="res://src/game/activity/prop/active/ActiveProp5001.cs" id="1_klvlf"] -[ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_2cgdl"] -[ext_resource type="SpriteFrames" uid="uid://bbjyakayescy5" path="res://resource/spriteFrames/prop/active/ActiveProp5001.tres" id="3_fagk1"] - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_mrkt4"] -resource_local_to_scene = true -shader = ExtResource("2_2cgdl") -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_2cgdl") -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="RectangleShape2D" id="RectangleShape2D_cpqup"] -size = Vector2(12, 10) - -[node name="ActiveProp5001" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")] -collision_layer = 4 -script = ExtResource("1_klvlf") -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 = ExtResource("3_fagk1") - -[node name="Collision" type="CollisionShape2D" parent="."] -shape = SubResource("RectangleShape2D_cpqup") diff --git a/DungeonShooting_Godot/resource/config/ActivePropBase.json b/DungeonShooting_Godot/resource/config/ActivePropBase.json index 0637a08..a60b2c5 100644 --- a/DungeonShooting_Godot/resource/config/ActivePropBase.json +++ b/DungeonShooting_Godot/resource/config/ActivePropBase.json @@ -1 +1,38 @@ -[] \ No newline at end of file +[ + { + "Id": "0001", + "Remark": "\u533B\u836F\u7BB1", + "__Activity": "prop5000", + "Buff": null, + "Condition": { + "HpFull": [ + 0 + ] + }, + "Effect": { + "Hp": [ + 2 + ] + }, + "CooldownTime": 0, + "IsConsumables": true, + "MaxCount": 10 + }, + { + "Id": "0002", + "Remark": "\u5F39\u836F\u7BB1", + "__Activity": "prop5001", + "Buff": null, + "Condition": { + "AmmoFull": [ + 0 + ] + }, + "Effect": { + "TotalAmmo": [] + }, + "CooldownTime": 0, + "IsConsumables": true, + "MaxCount": 10 + } +] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/config/ActivityBase.json b/DungeonShooting_Godot/resource/config/ActivityBase.json index d3b4456..5dcad8d 100644 --- a/DungeonShooting_Godot/resource/config/ActivityBase.json +++ b/DungeonShooting_Godot/resource/config/ActivityBase.json @@ -653,7 +653,7 @@ "Details": "", "IsStatic": false, "__Material": "", - "Prefab": "res://prefab/prop/active/ActiveProp5000.tscn", + "Prefab": "res://prefab/prop/ActiveProp.tscn", "Icon": "res://resource/sprite/prop/active/ActiveProp5000.png", "ShowInMapEditor": true }, @@ -667,7 +667,7 @@ "Details": "", "IsStatic": false, "__Material": "", - "Prefab": "res://prefab/prop/active/ActiveProp5001.tscn", + "Prefab": "res://prefab/prop/ActiveProp.tscn", "Icon": "res://resource/sprite/prop/active/ActiveProp5001.png", "ShowInMapEditor": true }, diff --git a/DungeonShooting_Godot/resource/config/BuffPropBase.json b/DungeonShooting_Godot/resource/config/BuffPropBase.json index c3373a0..c36fbb6 100644 --- a/DungeonShooting_Godot/resource/config/BuffPropBase.json +++ b/DungeonShooting_Godot/resource/config/BuffPropBase.json @@ -44,7 +44,7 @@ "Remark": "\u6740\u4F24\u5F39", "__Activity": "prop0005", "Buff": { - "Damage": [ + "BulletDamage": [ 2, 0.2 ] @@ -108,7 +108,7 @@ -8, 8 ], - "Damage": [ + "BulletDamage": [ 2, -0.35 ], diff --git a/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json b/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json index cfee938..93e8149 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json @@ -49,7 +49,7 @@ "RewardList": [ { "ErrorType": 0, - "Path": "resource/map/tileMaps/Test1/reward/Award1" + "Path": "resource/map/tileMaps/Test1/reward/Reward1" } ], "ShopList": [ 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 fc094ec..a2e1c92 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}]},{"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}]},{"Position":{"X":-67,"Y":50},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop5001","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":5.551115E-14}]},{"Position":{"X":-91,"Y":46},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop5001","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":5.551115E-14}]},{"Position":{"X":-92,"Y":74},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop5001","Weight":100,"Attr":null,"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}]},{"Position":{"X":-67,"Y":50},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop5001","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":5.551115E-14}]},{"Position":{"X":-91,"Y":46},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop5001","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":5.551115E-14}]},{"Position":{"X":-92,"Y":74},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop5001","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":5.551115E-14}]},{"Position":{"X":-26,"Y":-46},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop5000","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":5.551115E-14}]},{"Position":{"X":-52,"Y":-33},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop5000","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":5.551115E-14}]},{"Position":{"X":-79,"Y":-28},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop5000","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":5.551115E-14}]}]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/Preinstall.json new file mode 100644 index 0000000..a9f951a --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/Preinstall.json @@ -0,0 +1 @@ +[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/Preview.png b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/Preview.png new file mode 100644 index 0000000..0a8e500 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/Preview.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/Preview.png.import b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/Preview.png.import new file mode 100644 index 0000000..9941d49 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/Preview.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cugykjrqe8wil" +path="res://.godot/imported/Preview.png-d591ad3d03347a3f1bfee6cb6974156c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/map/tileMaps/Test1/reward/Reward1/Preview.png" +dest_files=["res://.godot/imported/Preview.png-d591ad3d03347a3f1bfee6cb6974156c.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/RoomInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/RoomInfo.json new file mode 100644 index 0000000..127f35b --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/RoomInfo.json @@ -0,0 +1 @@ +{"Position":{"X":-2,"Y":-5},"Size":{"X":10,"Y":11},"DoorAreaInfos":[],"GroupName":"Test1","RoomType":16,"RoomName":"Reward1","Weight":100,"Remark":""} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/TileInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/TileInfo.json new file mode 100644 index 0000000..9ee6549 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Reward1/TileInfo.json @@ -0,0 +1 @@ +{"NavigationVertices":[{"X":90,"Y":74},{"X":6,"Y":74},{"X":6,"Y":-26},{"X":90,"Y":-26}],"NavigationPolygon":[[0,1,2,3]],"Floor":[0,-2,0,3,0,-1,0,3,0,0,0,3,0,1,0,3,0,2,0,3,0,3,0,3,1,-2,0,3,1,-1,0,3,1,0,0,3,1,1,0,3,1,2,0,3,1,3,0,3,2,-2,0,3,2,-1,0,3,2,0,0,3,2,1,0,3,2,2,0,3,2,3,0,3,3,-2,0,3,3,-1,0,3,3,0,0,3,3,1,0,3,3,2,0,3,3,3,0,3,4,-2,0,3,4,-1,0,3,4,0,0,3,4,1,0,3,4,2,0,3,4,3,0,3,5,-2,0,3,5,-1,0,3,5,0,0,3,5,1,0,3,5,2,0,3,5,3,0,3],"CustomFloor1":[1,-2,2,2,6,1,-1,2,4,8,0,-1,2,1,7,0,-2,2,1,6,1,0,2,3,7,0,0,2,1,7,1,1,2,3,7,0,1,2,1,7,1,2,2,4,9,0,2,2,1,7,1,3,2,2,8,0,3,2,1,8,2,2,2,2,6,2,3,2,2,8,3,2,2,2,6,3,3,2,2,8,4,2,2,5,9,4,3,2,2,8,5,2,2,3,7,5,3,2,3,8,5,1,2,3,7,4,1,2,1,7,5,0,2,3,7,4,0,2,1,7,5,-1,2,3,7,4,-1,2,5,8,5,-2,2,3,6,4,-2,2,2,6,3,-1,2,2,8,3,-2,2,2,6,2,-1,2,2,8,2,-2,2,2,6],"CustomFloor2":[],"CustomFloor3":[],"CustomMiddle1":[],"CustomMiddle2":[],"CustomTop":[]} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/spriteFrames/prop/active/ActiveProp5000.tres b/DungeonShooting_Godot/resource/spriteFrames/prop/active/ActiveProp5000.tres deleted file mode 100644 index a1ecdb8..0000000 --- a/DungeonShooting_Godot/resource/spriteFrames/prop/active/ActiveProp5000.tres +++ /dev/null @@ -1,14 +0,0 @@ -[gd_resource type="SpriteFrames" load_steps=2 format=3 uid="uid://cvosq47nbdnus"] - -[ext_resource type="Texture2D" uid="uid://cu0wlvrbntvyd" path="res://resource/sprite/prop/active/ActiveProp5000.png" id="1_mkqgb"] - -[resource] -animations = [{ -"frames": [{ -"duration": 1.0, -"texture": ExtResource("1_mkqgb") -}], -"loop": true, -"name": &"default", -"speed": 5.0 -}] diff --git a/DungeonShooting_Godot/resource/spriteFrames/prop/active/ActiveProp5001.tres b/DungeonShooting_Godot/resource/spriteFrames/prop/active/ActiveProp5001.tres deleted file mode 100644 index c5cf932..0000000 --- a/DungeonShooting_Godot/resource/spriteFrames/prop/active/ActiveProp5001.tres +++ /dev/null @@ -1,14 +0,0 @@ -[gd_resource type="SpriteFrames" load_steps=2 format=3 uid="uid://bbjyakayescy5"] - -[ext_resource type="Texture2D" uid="uid://fby848tbodc" path="res://resource/sprite/prop/active/ActiveProp5001.png" id="1_1xlxo"] - -[resource] -animations = [{ -"frames": [{ -"duration": 1.0, -"texture": ExtResource("1_1xlxo") -}], -"loop": true, -"name": &"default", -"speed": 5.0 -}] diff --git a/DungeonShooting_Godot/src/config/ExcelConfig_ActivePropBase.cs b/DungeonShooting_Godot/src/config/ExcelConfig_ActivePropBase.cs index 0de39eb..db856d5 100644 --- a/DungeonShooting_Godot/src/config/ExcelConfig_ActivePropBase.cs +++ b/DungeonShooting_Godot/src/config/ExcelConfig_ActivePropBase.cs @@ -34,13 +34,36 @@ public Dictionary Buff; /// - /// 使用完成后是否自动销毁 + /// 道具使用条件
+ /// 参数配置方式与buff字段相同
+ /// 性名称请参阅condition属性表 ///
[JsonInclude] - public bool AutoDestroy; + public Dictionary Condition; /// - /// 最大叠加次数 + /// 道具使用效果
+ /// 参数配置方式与buff字段相同
+ /// 性名称请参阅effect属性表 + ///
+ [JsonInclude] + public Dictionary Effect; + + /// + /// 使用一次后的冷却时间
+ /// 单位: 秒 + ///
+ [JsonInclude] + public float CooldownTime; + + /// + /// 是否是消耗品, 如果为true, 则每次使用都会消耗叠加数量 + /// + [JsonInclude] + public bool IsConsumables; + + /// + /// 最大叠加次数, 仅当IsConsumables为true时有效 /// [JsonInclude] public uint MaxCount; @@ -55,7 +78,10 @@ inst.Remark = Remark; inst.Activity = Activity; inst.Buff = Buff; - inst.AutoDestroy = AutoDestroy; + inst.Condition = Condition; + inst.Effect = Effect; + inst.CooldownTime = CooldownTime; + inst.IsConsumables = IsConsumables; inst.MaxCount = MaxCount; return inst; } diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index a176256..0c2112e 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -91,7 +91,7 @@ //初始化配置表 ExcelConfig.Init(); PreinstallMarkManager.Init(); - BuffRegister.Init(); + PropFragmentRegister.Init(); //初始化房间配置数据 InitRoomConfig(); //初始化TileSet配置数据 @@ -102,6 +102,8 @@ Enemy.InitEnemyAttribute(); //初始化buff数据 BuffProp.InitBuffAttribute(); + //初始化主动道具数据 + ActiveProp.InitActiveAttribute(); DungeonConfig = new DungeonConfig(); DungeonConfig.GroupName = "Test1"; diff --git a/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs b/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs index fdc1b9d..0b5daab 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs @@ -1,5 +1,7 @@ +using System; using System.Collections.Generic; +using Config; using Godot; /// @@ -8,6 +10,11 @@ [Tool] public partial class ActiveProp : PropActivity, IPackageItem { + /// + /// 配置数据 + /// + public ExcelConfig.ActivePropBase Attribute { get; private set; } + public int PackageIndex { get; set; } /// @@ -52,18 +59,8 @@ } private int _maxCount = 1; - - /// - /// 使用一次后的冷却时间, 单位: 秒 - /// - public float CooldownTime { get; set; } = 2f; /// - /// 当道具使用完后是否自动销毁 - /// - public bool AutoDestroy { get; set; } = false; - - /// /// 道具充能进度, 必须要充能完成才能使用, 值范围: 0 - 1 /// public float ChargeProgress @@ -89,21 +86,192 @@ //冷却计时器 private float _cooldownTimer = 0; + + //被动属性 + private readonly List _buffFragment = new List(); + //条件 + private readonly List _conditionFragment = new List(); + //效果 + private readonly List _effectFragment = new List(); + + public override void OnInit() + { + base.OnInit(); + var buffAttribute = GetActiveAttribute(ActivityBase.Id); + Attribute = buffAttribute; + + //初始化buff属性 + if (buffAttribute.Buff != null) + { + foreach (var keyValuePair in buffAttribute.Buff) + { + var buffInfo = PropFragmentRegister.BuffFragmentInfos[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 (buffAttribute.Condition != null) + { + foreach (var keyValuePair in buffAttribute.Condition) + { + var buffInfo = PropFragmentRegister.ConditionFragmentInfos[keyValuePair.Key]; + var item = keyValuePair.Value; + switch (item.Length) + { + case 0: + { + var buff = (ConditionFragment)AddComponent(buffInfo.Type); + _conditionFragment.Add(buff); + } + break; + case 1: + { + var buff = (ConditionFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0]); + _conditionFragment.Add(buff); + } + break; + case 2: + { + var buff = (ConditionFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0], item[1]); + _conditionFragment.Add(buff); + } + break; + case 3: + { + var buff = (ConditionFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0], item[1], item[2]); + _conditionFragment.Add(buff); + } + break; + case 4: + { + var buff = (ConditionFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0], item[1], item[2], item[3]); + _conditionFragment.Add(buff); + } + break; + } + } + } + + //初始化效果属性 + if (buffAttribute.Effect != null) + { + foreach (var keyValuePair in buffAttribute.Effect) + { + var buffInfo = PropFragmentRegister.EffectFragmentInfos[keyValuePair.Key]; + var item = keyValuePair.Value; + switch (item.Length) + { + case 0: + { + var buff = (EffectFragment)AddComponent(buffInfo.Type); + _effectFragment.Add(buff); + } + break; + case 1: + { + var buff = (EffectFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0]); + _effectFragment.Add(buff); + } + break; + case 2: + { + var buff = (EffectFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0], item[1]); + _effectFragment.Add(buff); + } + break; + case 3: + { + var buff = (EffectFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0], item[1], item[2]); + _effectFragment.Add(buff); + } + break; + case 4: + { + var buff = (EffectFragment)AddComponent(buffInfo.Type); + buff.InitParam(item[0], item[1], item[2], item[3]); + _effectFragment.Add(buff); + } + break; + } + } + } + + //显示纹理 + if (!string.IsNullOrEmpty(ActivityBase.Icon)) + { + SetDefaultTexture(ResourceManager.LoadTexture2D(ActivityBase.Icon)); + } + + MaxCount = (int)Attribute.MaxCount; + } /// /// 当检测是否可以使用时调用 /// public virtual bool OnCheckUse() { + foreach (var fragment in _conditionFragment) + { + if (!fragment.OnCheckUse()) return false; + } + return true; } /// - /// 当道具被使用时调用, 函数返回值为消耗数量 + /// 当道具被使用时调用 /// - protected virtual int OnUse() + protected virtual void OnUse() { - return 1; + foreach (var fragment in _effectFragment) + { + fragment.OnUse(); + } } /// @@ -173,7 +341,7 @@ //检测是否达到自动销毁的条件 private bool CheckAutoDestroy() { - if (Count == 0 && AutoDestroy) //用光了, 自动销毁 + if (Count == 0 && Attribute.IsConsumables) //用光了, 自动销毁 { if (Master != null) { @@ -205,14 +373,14 @@ } if (CheckUse()) //可以使用道具 { - var num = OnUse(); - if (num != 0) + OnUse(); + if (Attribute.IsConsumables) { - Count -= num; + Count -= 1; } //冷却计时器 - _cooldownTimer = CooldownTime; + _cooldownTimer = Attribute.CooldownTime; } } @@ -226,7 +394,7 @@ return 1; } - return (CooldownTime - _cooldownTimer) / CooldownTime; + return (Attribute.CooldownTime - _cooldownTimer) / Attribute.CooldownTime; } public override void Interactive(ActivityObject master) @@ -309,10 +477,18 @@ public override void OnPickUpItem() { + foreach (var buffFragment in _buffFragment) + { + buffFragment.OnPickUpItem(); + } } public override void OnRemoveItem() { + foreach (var buffFragment in _buffFragment) + { + buffFragment.OnRemoveItem(); + } } public virtual void OnActiveItem() @@ -327,4 +503,119 @@ { Master.ThrowActiveProp(PackageIndex); } + + + /// + /// 添加被动属性 + /// + public void AddBuffFragment() where T : BuffFragment, new() + { + var fragment = AddComponent(); + _buffFragment.Add(fragment); + if (Master != null) + { + fragment.OnPickUpItem(); + } + } + + /// + /// 添加被动属性 + /// + public void AddBuffFragment(float arg1) where T : BuffFragment, new() + { + var fragment = AddComponent(); + _buffFragment.Add(fragment); + fragment.InitParam(arg1); + if (Master != null) + { + fragment.OnPickUpItem(); + } + } + + /// + /// 添加被动属性 + /// + public void AddBuffFragment(float arg1, float arg2) where T : BuffFragment, new() + { + var fragment = AddComponent(); + _buffFragment.Add(fragment); + fragment.InitParam(arg1, arg2); + if (Master != null) + { + fragment.OnPickUpItem(); + } + } + + /// + /// 添加被动属性 + /// + public void AddBuffFragment(float arg1, float arg2, float arg3) where T : BuffFragment, new() + { + var fragment = AddComponent(); + _buffFragment.Add(fragment); + fragment.InitParam(arg1, arg2, arg3); + if (Master != null) + { + fragment.OnPickUpItem(); + } + } + + /// + /// 添加被动属性 + /// + public void AddBuffFragment(float arg1, float arg2, float arg3, float arg4) where T : BuffFragment, new() + { + var fragment = AddComponent(); + _buffFragment.Add(fragment); + fragment.InitParam(arg1, arg2, arg3, arg4); + if (Master != null) + { + fragment.OnPickUpItem(); + } + } + + + private static bool _init = false; + private static Dictionary _activeAttributeMap = + new Dictionary(); + + /// + /// 初始化主动道具属性数据 + /// + public static void InitActiveAttribute() + { + if (_init) + { + return; + } + + _init = true; + foreach (var buffAttr in ExcelConfig.ActivePropBase_List) + { + if (buffAttr.Activity != null) + { + if (!_activeAttributeMap.TryAdd(buffAttr.Activity.Id, buffAttr)) + { + Debug.LogError("发现重复注册的主动道具属性: " + buffAttr.Id); + } + } + } + } + + /// + /// 根据 ActivityBase.Id 获取对应主动道具的属性数据 + /// + public static ExcelConfig.ActivePropBase GetActiveAttribute(string itemId) + { + if (itemId == null) + { + return null; + } + if (_activeAttributeMap.TryGetValue(itemId, out var attr)) + { + return attr; + } + + throw new Exception($"主动道具'{itemId}'没有在 ActivePropBase 表中配置属性数据!"); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/prop/BuffProp.cs b/DungeonShooting_Godot/src/game/activity/prop/BuffProp.cs index 5ed7bd9..c3139db 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/BuffProp.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/BuffProp.cs @@ -10,6 +10,11 @@ [Tool] public partial class BuffProp : PropActivity { + /// + /// 配置数据 + /// + public ExcelConfig.BuffPropBase Attribute { get; private set; } + //被动属性 private readonly List _buffFragment = new List(); @@ -17,12 +22,13 @@ { base.OnInit(); var buffAttribute = GetBuffAttribute(ActivityBase.Id); - if (buffAttribute != null) + Attribute = buffAttribute; + //初始化buff属性 + if (buffAttribute.Buff != null) { - //初始化buff属性 foreach (var keyValuePair in buffAttribute.Buff) { - var buffInfo = BuffRegister.BuffInfos[keyValuePair.Key]; + var buffInfo = PropFragmentRegister.BuffFragmentInfos[keyValuePair.Key]; var item = keyValuePair.Value; switch (item.Length) { @@ -62,11 +68,12 @@ break; } } - //显示纹理 - if (!string.IsNullOrEmpty(ActivityBase.Icon)) - { - SetDefaultTexture(ResourceManager.LoadTexture2D(ActivityBase.Icon)); - } + } + + //显示纹理 + if (!string.IsNullOrEmpty(ActivityBase.Icon)) + { + SetDefaultTexture(ResourceManager.LoadTexture2D(ActivityBase.Icon)); } } @@ -215,6 +222,6 @@ return attr; } - throw new Exception($"buff'{itemId}'没有在 BuffBase 表中配置属性数据!"); + throw new Exception($"buff'{itemId}'没有在 BuffPropBase 表中配置属性数据!"); } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs deleted file mode 100644 index 0f7d67c..0000000 --- a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs +++ /dev/null @@ -1,27 +0,0 @@ - -using Godot; - -/// -/// 医药箱, 使用后恢复一颗红心 -/// -[Tool] -public partial class ActiveProp5000 : ActiveProp -{ - public override void OnInit() - { - base.OnInit(); - AutoDestroy = true; - MaxCount = 10; - } - - public override bool OnCheckUse() - { - return !Master.IsHpFull(); - } - - protected override int OnUse() - { - Master.Hp += 2; - return 1; - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs deleted file mode 100644 index c19b1c9..0000000 --- a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs +++ /dev/null @@ -1,33 +0,0 @@ - -using Godot; - -/// -/// 弹药箱, 使用后补全当前武器备用弹药 -/// -[Tool] -public partial class ActiveProp5001 : ActiveProp -{ - public override void OnInit() - { - base.OnInit(); - AutoDestroy = true; - MaxCount = 10; - } - - public override bool OnCheckUse() - { - return Master.WeaponPack.ActiveItem != null && !Master.WeaponPack.ActiveItem.IsAmmoFull(); - } - - protected override int OnUse() - { - var weapon = Master.WeaponPack.ActiveItem; - if (weapon != null) - { - weapon.SetTotalAmmo(weapon.Attribute.MaxAmmoCapacity); - return 1; - } - - return 0; - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs index 1945689..584c4c9 100644 --- a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs +++ b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs @@ -45,6 +45,11 @@ /// 剩余弹药量(备用弹药) /// public int ResidueAmmo { get; private set; } + + /// + /// 总弹药量(备用弹药 + 当前弹夹弹药) + /// + public int TotalAmmon => CurrAmmo + ResidueAmmo; /// /// 武器管的开火点 diff --git a/DungeonShooting_Godot/src/game/buff/BuffAttribute.cs b/DungeonShooting_Godot/src/game/buff/BuffAttribute.cs deleted file mode 100644 index 2d44e2f..0000000 --- a/DungeonShooting_Godot/src/game/buff/BuffAttribute.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -[AttributeUsage(AttributeTargets.Class)] -public class BuffAttribute : Attribute -{ - /// - /// Buff属性名称 - /// - public string BuffName { get; set; } - - /// - /// 描述 - /// - public string Description { get; set; } - - public BuffAttribute(string buffName, string description) - { - BuffName = buffName; - Description = description; - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/BuffFragment.cs b/DungeonShooting_Godot/src/game/buff/BuffFragment.cs index 16f6110..7599706 100644 --- a/DungeonShooting_Godot/src/game/buff/BuffFragment.cs +++ b/DungeonShooting_Godot/src/game/buff/BuffFragment.cs @@ -4,14 +4,9 @@ /// /// 被动属性逻辑基类 /// -public abstract class BuffFragment : Component +public abstract class BuffFragment : PropFragment { /// - /// 所属角色对象 - /// - public Role Role => Master?.Master; - - /// /// 当道具被拾起时调用 (在 Master 赋值之后调用) /// public abstract void OnPickUpItem(); @@ -20,36 +15,4 @@ /// 当道具被移除时调用 (在 Master 置为 null 之前调用) /// public abstract void OnRemoveItem(); - - /// - /// 初始化被动属性参数 - /// - public virtual void InitParam(float arg1) - { - Debug.LogError($"'{GetType().FullName}'为实现1参数初始化函数!"); - } - - /// - /// 初始化被动属性参数 - /// - public virtual void InitParam(float arg1, float arg2) - { - Debug.LogError($"'{GetType().FullName}'为实现2参数初始化函数!"); - } - - /// - /// 初始化被动属性参数 - /// - public virtual void InitParam(float arg1, float arg2, float arg3) - { - Debug.LogError($"'{GetType().FullName}'为实现4参数初始化函数!"); - } - - /// - /// 初始化被动属性参数 - /// - public virtual void InitParam(float arg1, float arg2, float arg3, float arg4) - { - Debug.LogError($"'{GetType().FullName}'为实现4参数初始化函数!"); - } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/BuffFragmentAttribute.cs b/DungeonShooting_Godot/src/game/buff/BuffFragmentAttribute.cs new file mode 100644 index 0000000..bb12a62 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/BuffFragmentAttribute.cs @@ -0,0 +1,21 @@ +using System; + +[AttributeUsage(AttributeTargets.Class)] +public class BuffFragmentAttribute : Attribute +{ + /// + /// Buff属性名称 + /// + public string BuffName { get; set; } + + /// + /// 描述 + /// + public string Description { get; set; } + + public BuffFragmentAttribute(string buffName, string description) + { + BuffName = buffName; + Description = description; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/ConditionFragment.cs b/DungeonShooting_Godot/src/game/buff/ConditionFragment.cs new file mode 100644 index 0000000..c8b8d45 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/ConditionFragment.cs @@ -0,0 +1,11 @@ + +/// +/// 主动道具使用条件基类 +/// +public abstract class ConditionFragment : PropFragment +{ + /// + /// 当检测是否可以使用时调用 + /// + public abstract bool OnCheckUse(); +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/ConditionFragmentAttribute.cs b/DungeonShooting_Godot/src/game/buff/ConditionFragmentAttribute.cs new file mode 100644 index 0000000..1d9191e --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/ConditionFragmentAttribute.cs @@ -0,0 +1,22 @@ + +using System; + +[AttributeUsage(AttributeTargets.Class)] +public class ConditionFragmentAttribute : Attribute +{ + /// + /// 条件名称 + /// + public string ConditionName { get; set; } + + /// + /// 描述 + /// + public string Description { get; set; } + + public ConditionFragmentAttribute(string conditionName, string description) + { + ConditionName = conditionName; + Description = description; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/EffectFragment.cs b/DungeonShooting_Godot/src/game/buff/EffectFragment.cs new file mode 100644 index 0000000..d971d8f --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/EffectFragment.cs @@ -0,0 +1,11 @@ + +/// +/// 主动道具使用效果基类 +/// +public abstract class EffectFragment : PropFragment +{ + /// + /// 使用道具的回调 + /// + public abstract void OnUse(); +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/EffectFragmentAttribute.cs b/DungeonShooting_Godot/src/game/buff/EffectFragmentAttribute.cs new file mode 100644 index 0000000..3a5f9fc --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/EffectFragmentAttribute.cs @@ -0,0 +1,21 @@ +using System; + +[AttributeUsage(AttributeTargets.Class)] +public class EffectFragmentAttribute : Attribute +{ + /// + /// 效果名称 + /// + public string EffectName { get; set; } + + /// + /// 描述 + /// + public string Description { get; set; } + + public EffectFragmentAttribute(string effectName, string description) + { + EffectName = effectName; + Description = description; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/PropFragment.cs b/DungeonShooting_Godot/src/game/buff/PropFragment.cs new file mode 100644 index 0000000..5dcd749 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/PropFragment.cs @@ -0,0 +1,43 @@ + +/// +/// 道具逻辑片段组件 +/// +public abstract class PropFragment : Component +{ + /// + /// 所属角色对象 + /// + public Role Role => Master?.Master; + + /// + /// 初始化被动属性参数 + /// + public virtual void InitParam(float arg1) + { + Debug.LogError($"'{GetType().FullName}'为实现1参数初始化函数!"); + } + + /// + /// 初始化被动属性参数 + /// + public virtual void InitParam(float arg1, float arg2) + { + Debug.LogError($"'{GetType().FullName}'为实现2参数初始化函数!"); + } + + /// + /// 初始化被动属性参数 + /// + public virtual void InitParam(float arg1, float arg2, float arg3) + { + Debug.LogError($"'{GetType().FullName}'为实现4参数初始化函数!"); + } + + /// + /// 初始化被动属性参数 + /// + public virtual void InitParam(float arg1, float arg2, float arg3, float arg4) + { + Debug.LogError($"'{GetType().FullName}'为实现4参数初始化函数!"); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_ActivePropsCapacity.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_ActivePropsCapacity.cs index 7163a9d..6804fb9 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_ActivePropsCapacity.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_ActivePropsCapacity.cs @@ -1,5 +1,5 @@ -[Buff("ActivePropsCapacity", "主动道具背包容量 buff, 参数‘1’为主动道具背包增加的容量")] +[BuffFragment("ActivePropsCapacity", "主动道具背包容量 buff, 参数‘1’为主动道具背包增加的容量")] public class Buff_ActivePropsCapacity : BuffFragment { private int _value; diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletBounceCount.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletBounceCount.cs index 1f57944..b68ac1a 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletBounceCount.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletBounceCount.cs @@ -1,5 +1,5 @@ -[Buff("BulletBounceCount", "子弹弹射数量 buff, 参数‘1’为增加的弹射次数")] +[BuffFragment("BulletBounceCount", "子弹弹射数量 buff, 参数‘1’为增加的弹射次数")] public class Buff_BulletBounceCount : BuffFragment { private int _value; diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletCount.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletCount.cs index 71b3cfd..8f1bf17 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletCount.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletCount.cs @@ -1,7 +1,7 @@ using Godot; -[Buff("BulletCount", +[BuffFragment("BulletCount", "子弹数量 buff, " + "参数‘1’为子弹数量添加类型, 1: 具体数量, 2:百分比(小数), " + "参数‘2’为增加子弹的数量")] diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDamage.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDamage.cs new file mode 100644 index 0000000..93f13f6 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDamage.cs @@ -0,0 +1,67 @@ + +using Godot; + +[BuffFragment("BulletDamage", + "提升子弹伤害buff, " + + "参数‘1’为伤害增加类型: 1:具体伤害, 2:百分比伤害(小数), " + + "参数‘2’为增益伤害值")] +public class Buff_BulletDamage : BuffFragment +{ + private int _type; + private float _value; + + public override void InitParam(float arg1, float arg2) + { + _type = (int)arg1; + _value = arg2; + } + + public override void OnPickUpItem() + { + if (_type == 1) + { + Role.RoleState.CalcDamageEvent += CalcDamage1; + } + else + { + Role.RoleState.CalcDamageEvent += CalcDamage2; + } + } + + public override void OnRemoveItem() + { + if (_type == 1) + { + Role.RoleState.CalcDamageEvent -= CalcDamage1; + } + else + { + Role.RoleState.CalcDamageEvent -= CalcDamage2; + } + } + + private void CalcDamage1(int originDamage, RefValue refValue) + { + if (Role.WeaponPack.ActiveItem != null && Role.WeaponPack.ActiveItem.Attribute.IsMelee) + { + return; + } + refValue.Value += Mathf.CeilToInt(_value); + } + + private void CalcDamage2(int originDamage, RefValue refValue) + { + if (Role.WeaponPack.ActiveItem != null && Role.WeaponPack.ActiveItem.Attribute.IsMelee) + { + return; + } + 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/buff/Buff_BulletDeviationAngle.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDeviationAngle.cs index 2a7ecf8..fe3f7bb 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDeviationAngle.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDeviationAngle.cs @@ -1,5 +1,5 @@ -[Buff("BulletDeviationAngle", +[BuffFragment("BulletDeviationAngle", "子弹偏移角度 buff, " + "参数‘1’为增加子弹偏移角度下限, " + "参数‘2’为增加子弹偏移角度上限, 单位角度制, 会从上限和下限随机抽取值")] diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDistance.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDistance.cs index b394049..595022b 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDistance.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDistance.cs @@ -1,5 +1,5 @@ -[Buff("BulletDistance", +[BuffFragment("BulletDistance", "子弹射程 buff, " + "参数‘1’为射程增加类型: 1:具体射程, 2:百分比射程(小数), " + "参数‘2’为子弹增加的射程值")] diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletPenetration.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletPenetration.cs index 89040fa..eb0732f 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletPenetration.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletPenetration.cs @@ -1,5 +1,5 @@ -[Buff("BulletPenetration", "子弹穿透次数 buff, 参数‘1’为增加的穿透次数")] +[BuffFragment("BulletPenetration", "子弹穿透次数 buff, 参数‘1’为增加的穿透次数")] public class Buff_BulletPenetration : BuffFragment { private int _value; diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletRepel.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletRepel.cs index 51e7ca7..9e711f6 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletRepel.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletRepel.cs @@ -1,7 +1,7 @@ using Godot; -[Buff("BulletRepel", +[BuffFragment("BulletRepel", "子弹击退 buff, " + "参数‘1’为击退增加类型: 1:具体击退值, 2:百分比击退值(小数), " + "参数‘2’为子弹增加的击退值")] diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletSpeed.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletSpeed.cs index b438e39..a8c9ffa 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletSpeed.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletSpeed.cs @@ -1,5 +1,5 @@ -[Buff("BulletSpeed", +[BuffFragment("BulletSpeed", "子弹速度 buff, " + "参数‘1’为射速增加类型: 1:具体射速, 2:百分比射速(小数), " + "参数‘2’为子弹增加的射速值")] diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_Damage.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_Damage.cs deleted file mode 100644 index e5eb3c6..0000000 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_Damage.cs +++ /dev/null @@ -1,59 +0,0 @@ - -using Godot; - -[Buff("Damage", - "提升伤害buff, " + - "参数‘1’为伤害增加类型: 1:具体伤害, 2:百分比伤害(小数), " + - "参数‘2’为增益伤害值")] -public class Buff_Damage : BuffFragment -{ - private int _type; - private float _value; - - public override void InitParam(float arg1, float arg2) - { - _type = (int)arg1; - _value = arg2; - } - - public override void OnPickUpItem() - { - if (_type == 1) - { - Role.RoleState.CalcDamageEvent += CalcDamage1; - } - else - { - Role.RoleState.CalcDamageEvent += CalcDamage2; - } - } - - public override void OnRemoveItem() - { - if (_type == 1) - { - Role.RoleState.CalcDamageEvent -= CalcDamage1; - } - else - { - Role.RoleState.CalcDamageEvent -= CalcDamage2; - } - } - - private void CalcDamage1(int originDamage, RefValue refValue) - { - refValue.Value += Mathf.CeilToInt(_value); - } - - private void CalcDamage2(int originDamage, RefValue refValue) - { - 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/buff/Buff_MaxHp.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxHp.cs index bb6fea6..8e7a107 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxHp.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxHp.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -[Buff("MaxHp", "血量上限 buff, 参数‘1’为血量上限值")] +[BuffFragment("MaxHp", "血量上限 buff, 参数‘1’为血量上限值")] public class Buff_MaxHp : BuffFragment { private List _cacheId = new List(); diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxShield.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxShield.cs index c63c816..20ade21 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxShield.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxShield.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -[Buff("MaxShield", "护盾上限buff, 参数‘1’为护盾上限")] +[BuffFragment("MaxShield", "护盾上限buff, 参数‘1’为护盾上限")] public class Buff_MaxShield : BuffFragment { private List _cacheId = new List(); diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_MoveSpeed.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_MoveSpeed.cs index 880ef7f..e528c47 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_MoveSpeed.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_MoveSpeed.cs @@ -1,5 +1,5 @@ -[Buff("MoveSpeed", "移速 buff, 参数‘1’为移动速度值")] +[BuffFragment("MoveSpeed", "移速 buff, 参数‘1’为移动速度值")] public class Buff_MoveSpeed : BuffFragment { private float _moveSpeed; diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_OffsetInjury.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_OffsetInjury.cs index c617952..008abe0 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_OffsetInjury.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_OffsetInjury.cs @@ -1,5 +1,5 @@ -[Buff("OffsetInjury", "受伤时有概率抵消伤害的buff, 参数‘1’为抵消伤害概率百分比(小数)")] +[BuffFragment("OffsetInjury", "受伤时有概率抵消伤害的buff, 参数‘1’为抵消伤害概率百分比(小数)")] public class Buff_OffsetInjury : BuffFragment { private float _value; diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_RandomBulletSpeed.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_RandomBulletSpeed.cs index d70518d..c2d1ab0 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_RandomBulletSpeed.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_RandomBulletSpeed.cs @@ -1,5 +1,5 @@ -[Buff("RandomBulletSpeed", +[BuffFragment("RandomBulletSpeed", "子弹增加随机速度 buff, " + "参数‘1’为增加子弹速度下限, " + "参数‘2’为增加子弹速度上限, 会从上限和下限随机抽取值")] diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_Scattering.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_Scattering.cs index 00fdc81..edee925 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_Scattering.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_Scattering.cs @@ -1,7 +1,7 @@ using Godot; -[Buff("Scattering", "提高武器精准度buff, 参数‘1’为提升的精准度百分比值(小数)")] +[BuffFragment("Scattering", "提高武器精准度buff, 参数‘1’为提升的精准度百分比值(小数)")] public class Buff_Scattering : BuffFragment { private float _value; diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_ShieldRecoveryTime.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_ShieldRecoveryTime.cs index a70d11a..88bb3df 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_ShieldRecoveryTime.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_ShieldRecoveryTime.cs @@ -1,5 +1,5 @@ -[Buff("ShieldRecoveryTime", "单格护盾减少的恢复时间, 参数‘1’单位: 秒")] +[BuffFragment("ShieldRecoveryTime", "单格护盾减少的恢复时间, 参数‘1’单位: 秒")] public class Buff_ShieldRecoveryTime : BuffFragment { private float _time; diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_WeaponCapacity.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_WeaponCapacity.cs index fd7ef35..10b986a 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_WeaponCapacity.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_WeaponCapacity.cs @@ -1,5 +1,5 @@ -[Buff("WeaponCapacity", "武器背包容量 buff, 参数‘1’为武器背包增加的容量")] +[BuffFragment("WeaponCapacity", "武器背包容量 buff, 参数‘1’为武器背包增加的容量")] public class Buff_WeaponCapacity : BuffFragment { private int _value; diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_WoundedInvincibleTime.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_WoundedInvincibleTime.cs index f7184ab..27b84ca 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_WoundedInvincibleTime.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_WoundedInvincibleTime.cs @@ -1,5 +1,5 @@ -[Buff("WoundedInvincibleTime", "延长无敌时间buff, 参数‘1’为延长时间, 单位秒")] +[BuffFragment("WoundedInvincibleTime", "延长无敌时间buff, 参数‘1’为延长时间, 单位秒")] public class Buff_WoundedInvincibleTime : BuffFragment { private float _time; diff --git a/DungeonShooting_Godot/src/game/buff/condition/Cond_AmmoFull.cs b/DungeonShooting_Godot/src/game/buff/condition/Cond_AmmoFull.cs new file mode 100644 index 0000000..189f9e3 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/condition/Cond_AmmoFull.cs @@ -0,0 +1,29 @@ + +[ConditionFragment("AmmoFull", + "判断当前武器弹药状态, " + + "参数1可选值: 0:判断非满弹药, 1:判断满弹药")] +public class Cond_AmmoFull : ConditionFragment +{ + private int _type; + + public override void InitParam(float arg1) + { + _type = (int)arg1; + } + + public override bool OnCheckUse() + { + if (Role.WeaponPack.ActiveItem == null) + { + return false; + } + if (_type == 0) + { + return !Role.WeaponPack.ActiveItem.IsAmmoFull(); + } + else + { + return Role.WeaponPack.ActiveItem.IsAmmoFull(); + } + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/condition/Cond_HpFull.cs b/DungeonShooting_Godot/src/game/buff/condition/Cond_HpFull.cs new file mode 100644 index 0000000..a6ff375 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/condition/Cond_HpFull.cs @@ -0,0 +1,25 @@ + +[ConditionFragment("HpFull", + "判断满血状态, " + + "参数1可选值: 0:判断非满血, 1:判断满血")] +public class Cond_HpFull : ConditionFragment +{ + private int _type; + + public override void InitParam(float arg1) + { + _type = (int)arg1; + } + + public override bool OnCheckUse() + { + if (_type == 0) + { + return !Role.IsHpFull(); + } + else + { + return Role.IsHpFull(); + } + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/effect/Eff_Hp.cs b/DungeonShooting_Godot/src/game/buff/effect/Eff_Hp.cs new file mode 100644 index 0000000..1dc96e6 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/effect/Eff_Hp.cs @@ -0,0 +1,16 @@ + +[EffectFragment("Hp", "修改血量, 参数1为血量变化的具体值")] +public class Eff_Hp : EffectFragment +{ + private int _value; + + public override void InitParam(float arg1) + { + _value = (int) arg1; + } + + public override void OnUse() + { + Role.Hp += _value; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/effect/Eff_TotalAmmo.cs b/DungeonShooting_Godot/src/game/buff/effect/Eff_TotalAmmo.cs new file mode 100644 index 0000000..6984e62 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/effect/Eff_TotalAmmo.cs @@ -0,0 +1,28 @@ + +[EffectFragment("TotalAmmo", + "修改武器总弹药量, " + + "参数1(选填)为弹药变化的具体值, 如果不传则表示补满弹药")] +public class Eff_TotalAmmo : EffectFragment +{ + private bool _initParam = false; + private int _value; + + public override void InitParam(float arg1) + { + _initParam = true; + _value = (int) arg1; + } + + public override void OnUse() + { + var weapon = Role.WeaponPack.ActiveItem; + if (_initParam) + { + weapon.SetTotalAmmo(weapon.TotalAmmon + _value); + } + else + { + weapon.SetTotalAmmo(weapon.Attribute.MaxAmmoCapacity); + } + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/data/BuffInfo.cs b/DungeonShooting_Godot/src/game/data/BuffInfo.cs deleted file mode 100644 index 08e185a..0000000 --- a/DungeonShooting_Godot/src/game/data/BuffInfo.cs +++ /dev/null @@ -1,45 +0,0 @@ - -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/data/PropFragmentInfo.cs b/DungeonShooting_Godot/src/game/data/PropFragmentInfo.cs new file mode 100644 index 0000000..578ad43 --- /dev/null +++ b/DungeonShooting_Godot/src/game/data/PropFragmentInfo.cs @@ -0,0 +1,30 @@ + +using System; + +/// +/// 道具逻辑片段数据 +/// +public class PropFragmentInfo +{ + /// + /// buff 名称 + /// + public string Name; + + /// + /// buff 描述 + /// + public string Description; + + /// + /// buff 类 + /// + public Type Type; + + public PropFragmentInfo(string name, string description, Type type) + { + Name = name; + Description = description; + 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 deleted file mode 100644 index 22bfa72..0000000 --- a/DungeonShooting_Godot/src/game/manager/BuffRegister.cs +++ /dev/null @@ -1,37 +0,0 @@ -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("RandomBulletSpeed", new BuffInfo("RandomBulletSpeed", null, new List() { 2 }, typeof(Buff_RandomBulletSpeed))); - 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/manager/PropFragmentRegister.cs b/DungeonShooting_Godot/src/game/manager/PropFragmentRegister.cs new file mode 100644 index 0000000..3dcb7e5 --- /dev/null +++ b/DungeonShooting_Godot/src/game/manager/PropFragmentRegister.cs @@ -0,0 +1,91 @@ +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Godot; + +/// +/// buff 属性注册类, 调用 Init() 函数初始化数据 +/// +public class PropFragmentRegister +{ + /// + /// 所有 buff 属性信息 + /// + public static Dictionary BuffFragmentInfos { get; private set; } + + /// + /// 所有主动道具条件数据 + /// + public static Dictionary ConditionFragmentInfos { get; private set; } + + /// + /// 所有主动道具效果数据 + /// + public static Dictionary EffectFragmentInfos { get; private set; } + + /// + /// 初始化 buff + /// + public static void Init() + { + BuffFragmentInfos = new Dictionary(); + ConditionFragmentInfos = new Dictionary(); + EffectFragmentInfos = new Dictionary(); + + var types = typeof(PropFragmentRegister).Assembly.GetTypes(); + //包含[BuffAttribute]特性 + var buffs = types.Where(type => + type.IsClass && !type.IsAbstract && type.IsAssignableTo(typeof(BuffFragment))); + foreach (var type in buffs) + { + var attribute = (BuffFragmentAttribute)type.GetCustomAttribute(typeof(BuffFragmentAttribute), false); + if (attribute != null) + { + if (BuffFragmentInfos.ContainsKey(attribute.BuffName)) + { + GD.PrintErr($"Buff '{attribute.BuffName}' 重名!"); + continue; + } + + var buffInfo = new PropFragmentInfo(attribute.BuffName, attribute.Description, type); + BuffFragmentInfos.Add(attribute.BuffName, buffInfo); + } + } + //包含[ConditionAttribute]特性 + var conditions = types.Where(type => + type.IsClass && !type.IsAbstract && type.IsAssignableTo(typeof(ConditionFragment))); + foreach (var type in conditions) + { + var attribute = (ConditionFragmentAttribute)type.GetCustomAttribute(typeof(ConditionFragmentAttribute), false); + if (attribute != null) + { + if (ConditionFragmentInfos.ContainsKey(attribute.ConditionName)) + { + GD.PrintErr($"Condition '{attribute.ConditionName}' 重名!"); + continue; + } + + var conditionInfo = new PropFragmentInfo(attribute.ConditionName, attribute.Description, type); + ConditionFragmentInfos.Add(attribute.ConditionName, conditionInfo); + } + } + //包含[EffectAttribute]特性 + var effects = types.Where(type => + type.IsClass && !type.IsAbstract && type.IsAssignableTo(typeof(EffectFragment))); + foreach (var type in effects) + { + var attribute = (EffectFragmentAttribute)type.GetCustomAttribute(typeof(EffectFragmentAttribute), false); + if (attribute != null) + { + if (EffectFragmentInfos.ContainsKey(attribute.EffectName)) + { + GD.PrintErr($"Effect '{attribute.EffectName}' 重名!"); + continue; + } + + var effectInfo = new PropFragmentInfo(attribute.EffectName, attribute.Description, type); + EffectFragmentInfos.Add(attribute.EffectName, effectInfo); + } + } + } +} \ No newline at end of file