diff --git a/DungeonShooting_Godot/excel/ActivePropBase.xlsx b/DungeonShooting_Godot/excel/ActivePropBase.xlsx new file mode 100644 index 0000000..260a154 --- /dev/null +++ b/DungeonShooting_Godot/excel/ActivePropBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/prefab/prop/BuffActivity.tscn b/DungeonShooting_Godot/prefab/prop/BuffActivity.tscn deleted file mode 100644 index 1e55321..0000000 --- a/DungeonShooting_Godot/prefab/prop/BuffActivity.tscn +++ /dev/null @@ -1,52 +0,0 @@ -[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/prefab/prop/BuffProp.tscn b/DungeonShooting_Godot/prefab/prop/BuffProp.tscn new file mode 100644 index 0000000..34aa0c4 --- /dev/null +++ b/DungeonShooting_Godot/prefab/prop/BuffProp.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/BuffProp.cs" id="1_nlcp6"] +[ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_imicp"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_mrkt4"] +resource_local_to_scene = true +shader = ExtResource("2_imicp") +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_imicp") +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="BuffProp" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")] +collision_layer = 4 +script = ExtResource("1_nlcp6") +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/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index 3121c92..a176256 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -101,7 +101,7 @@ //初始化敌人数据 Enemy.InitEnemyAttribute(); //初始化buff数据 - BuffActivity.InitBuffAttribute(); + BuffProp.InitBuffAttribute(); 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 new file mode 100644 index 0000000..fdc1b9d --- /dev/null +++ b/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs @@ -0,0 +1,330 @@ + +using System.Collections.Generic; +using Godot; + +/// +/// 主动使用道具 +/// +[Tool] +public partial class ActiveProp : PropActivity, IPackageItem +{ + public int PackageIndex { get; set; } + + /// + /// 道具可使用次数 + /// + public int Count + { + get => _count; + set + { + var temp = _count; + _count = Mathf.Clamp(value, 0, _maxCount); + if (temp != _count) + { + OnChangeCount(); + } + } + } + + private int _count = 1; + + /// + /// 道具最大叠加用次数 + /// + public int MaxCount + { + get => _maxCount; + set + { + var temp = _maxCount; + _maxCount = Mathf.Max(1, value); + if (temp != _maxCount) + { + OnChangeMaxCount(); + } + + if (Count > _maxCount) + { + Count = _maxCount; + } + } + } + + private int _maxCount = 1; + + /// + /// 使用一次后的冷却时间, 单位: 秒 + /// + public float CooldownTime { get; set; } = 2f; + + /// + /// 当道具使用完后是否自动销毁 + /// + public bool AutoDestroy { get; set; } = false; + + /// + /// 道具充能进度, 必须要充能完成才能使用, 值范围: 0 - 1 + /// + public float ChargeProgress + { + get => _chargeProgress; + set + { + var temp = _chargeProgress; + _chargeProgress = Mathf.Clamp(value, 0, 1); + if (temp != _chargeProgress) + { + OnChangeChargeProgress(); + } + } + } + + private float _chargeProgress = 1; + + /// + /// 自动充能速度, 也就是每秒充能进度, 如果为0则表示不就行自动充能 + /// + public float AutoChargeSpeed { get; set; } + + //冷却计时器 + private float _cooldownTimer = 0; + + /// + /// 当检测是否可以使用时调用 + /// + public virtual bool OnCheckUse() + { + return true; + } + + /// + /// 当道具被使用时调用, 函数返回值为消耗数量 + /// + protected virtual int OnUse() + { + return 1; + } + + /// + /// 道具数量改变时调用 + /// + protected virtual void OnChangeCount() + { + } + + /// + /// 道具最大数量改变时调用 + /// + protected virtual void OnChangeMaxCount() + { + } + + /// + /// 道具充能进度改变时调用 + /// + protected virtual void OnChangeChargeProgress() + { + } + + /// + /// 冷却完成时调用 + /// + protected virtual void OnCooldownFinish() + { + } + + protected override void Process(float delta) + { + RunUpdate(delta); + } + + public override void PackProcess(float delta) + { + RunUpdate(delta); + } + + private void RunUpdate(float delta) + { + if (CheckAutoDestroy()) + { + return; + } + //冷却 + if (_cooldownTimer > 0) + { + _cooldownTimer -= delta; + + //冷却完成 + if (_cooldownTimer <= 0) + { + _cooldownTimer = 0; + OnCooldownFinish(); + } + } + + //自动充能 + if (AutoChargeSpeed > 0 && ChargeProgress < 1) + { + ChargeProgress += AutoChargeSpeed * delta; + } + } + + //检测是否达到自动销毁的条件 + private bool CheckAutoDestroy() + { + if (Count == 0 && AutoDestroy) //用光了, 自动销毁 + { + if (Master != null) + { + Master.ActivePropsPack.RemoveItem(this); + } + Destroy(); + return true; + } + + return false; + } + + /// + /// 检测是否可以使用当前道具 + /// + public bool CheckUse() + { + return ChargeProgress >= 1 && _cooldownTimer <= 0 && Count > 0 && OnCheckUse(); + } + + /// + /// 触发使用道具 + /// + public void Use() + { + if (Master == null) + { + return; + } + if (CheckUse()) //可以使用道具 + { + var num = OnUse(); + if (num != 0) + { + Count -= num; + } + + //冷却计时器 + _cooldownTimer = CooldownTime; + } + } + + /// + /// 获取冷却进度 0 - 1 + /// + public float GetCooldownProgress() + { + if (_cooldownTimer <= 0) + { + return 1; + } + + return (CooldownTime - _cooldownTimer) / CooldownTime; + } + + public override void Interactive(ActivityObject master) + { + if (master is Player player) + { + if (player.ActivePropsPack.Capacity == 0) + { + //容量为0 + return; + } + var item = player.ActivePropsPack.GetItemById(ActivityBase.Id); + if (item == null) //没有同类型物体 + { + if (!player.ActivePropsPack.HasVacancy()) //没有空位置, 扔掉当前道具 + { + player.ThrowActiveProp(player.ActivePropsPack.ActiveIndex); + } + //替换手中的道具 + if (player.PickUpActiveProp(this)) + { + Pickup(); + } + } + else + { + //处理同类型道具 + if (item.Count < item.MaxCount) //允许叠加 + { + if (item.Count + Count > item.MaxCount) + { + Count -= item.MaxCount - item.Count; + item.Count = item.MaxCount; + } + else + { + item.Count += Count; + Count = 0; + } + Destroy(); + } + } + } + } + + public override CheckInteractiveResult CheckInteractive(ActivityObject master) + { + if (master is Player player) + { + if (player.ActivePropsPack.Capacity == 0) + { + //容量为0 + return new CheckInteractiveResult(this); + } + //查找相同类型的道具 + var item = player.ActivePropsPack.GetItemById(ActivityBase.Id); + if (item == null) //没有同类型物体 + { + if (player.ActivePropsPack.HasVacancy()) //还有空位, 拾起道具 + { + return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.PickUp); + } + + //替换手中的道具 + return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Replace); + } + + //处理同类型道具 + if (item.Count < item.MaxCount) //允许叠加 + { + return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Bullet); + } + + //该道具不能拾起 + return new CheckInteractiveResult(this); + } + + return new CheckInteractiveResult(this); + } + + public override void OnPickUpItem() + { + } + + public override void OnRemoveItem() + { + } + + public virtual void OnActiveItem() + { + } + + public virtual void OnConcealItem() + { + } + + public virtual void OnOverflowItem() + { + Master.ThrowActiveProp(PackageIndex); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/prop/BuffActivity.cs b/DungeonShooting_Godot/src/game/activity/prop/BuffActivity.cs deleted file mode 100644 index fec77ba..0000000 --- a/DungeonShooting_Godot/src/game/activity/prop/BuffActivity.cs +++ /dev/null @@ -1,220 +0,0 @@ - -using System; -using System.Collections.Generic; -using Config; -using Godot; - -/// -/// 通用被动道具实体类 -/// -[Tool] -public partial class BuffActivity : PropActivity -{ - //被动属性 - 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) - { - buffFragment.OnPickUpItem(); - } - } - - public override void OnRemoveItem() - { - foreach (var buffFragment in _buffFragment) - { - buffFragment.OnRemoveItem(); - } - } - - /// - /// 添加被动属性 - /// - 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(); - } - } - - public override void Interactive(ActivityObject master) - { - if (master is Player role) - { - Pickup(); - role.PickUpBuffProp(this); - } - } - - public override CheckInteractiveResult CheckInteractive(ActivityObject master) - { - if (master is Player) - { - return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.PickUp); - } - 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.BuffPropBase_List) - { - if (buffAttr.Activity != null) - { - if (!_buffAttributeMap.TryAdd(buffAttr.Activity.Id, buffAttr)) - { - Debug.LogError("发现重复注册的 buff 属性: " + buffAttr.Id); - } - } - } - } - - /// - /// 根据 ActivityBase.Id 获取对应 buff 的属性数据 - /// - public static ExcelConfig.BuffPropBase GetBuffAttribute(string itemId) - { - if (itemId == null) - { - return null; - } - if (_buffAttributeMap.TryGetValue(itemId, out var attr)) - { - return attr; - } - - throw new Exception($"buff'{itemId}'没有在 BuffBase 表中配置属性数据!"); - } -} \ 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 new file mode 100644 index 0000000..5ed7bd9 --- /dev/null +++ b/DungeonShooting_Godot/src/game/activity/prop/BuffProp.cs @@ -0,0 +1,220 @@ + +using System; +using System.Collections.Generic; +using Config; +using Godot; + +/// +/// 通用被动道具实体类 +/// +[Tool] +public partial class BuffProp : PropActivity +{ + //被动属性 + 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) + { + buffFragment.OnPickUpItem(); + } + } + + public override void OnRemoveItem() + { + foreach (var buffFragment in _buffFragment) + { + buffFragment.OnRemoveItem(); + } + } + + /// + /// 添加被动属性 + /// + 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(); + } + } + + public override void Interactive(ActivityObject master) + { + if (master is Player role) + { + Pickup(); + role.PickUpBuffProp(this); + } + } + + public override CheckInteractiveResult CheckInteractive(ActivityObject master) + { + if (master is Player) + { + return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.PickUp); + } + 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.BuffPropBase_List) + { + if (buffAttr.Activity != null) + { + if (!_buffAttributeMap.TryAdd(buffAttr.Activity.Id, buffAttr)) + { + Debug.LogError("发现重复注册的 buff 属性: " + buffAttr.Id); + } + } + } + } + + /// + /// 根据 ActivityBase.Id 获取对应 buff 的属性数据 + /// + public static ExcelConfig.BuffPropBase GetBuffAttribute(string itemId) + { + if (itemId == null) + { + return null; + } + if (_buffAttributeMap.TryGetValue(itemId, out var attr)) + { + return attr; + } + + throw new Exception($"buff'{itemId}'没有在 BuffBase 表中配置属性数据!"); + } +} \ 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 index 29d77b4..0f7d67c 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs @@ -5,14 +5,13 @@ /// 医药箱, 使用后恢复一颗红心 /// [Tool] -public partial class ActiveProp5000 : ActivePropActivity +public partial class ActiveProp5000 : ActiveProp { public override void OnInit() { base.OnInit(); AutoDestroy = true; MaxCount = 10; - Superposition = true; } public override bool OnCheckUse() diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs index 6940fdf..c19b1c9 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs @@ -5,12 +5,11 @@ /// 弹药箱, 使用后补全当前武器备用弹药 /// [Tool] -public partial class ActiveProp5001 : ActivePropActivity +public partial class ActiveProp5001 : ActiveProp { public override void OnInit() { base.OnInit(); - Superposition = true; AutoDestroy = true; MaxCount = 10; } diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActivePropActivity.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActivePropActivity.cs deleted file mode 100644 index cd1600c..0000000 --- a/DungeonShooting_Godot/src/game/activity/prop/active/ActivePropActivity.cs +++ /dev/null @@ -1,327 +0,0 @@ - -using Godot; - -/// -/// 主动使用道具 -/// -public abstract partial class ActivePropActivity : PropActivity, IPackageItem -{ - public int PackageIndex { get; set; } - - /// - /// 道具是否可以叠加 - /// - public bool Superposition { get; set; } = false; - - /// - /// 道具可使用次数 - /// - public int Count - { - get => _count; - set - { - var temp = _count; - _count = Mathf.Clamp(value, 0, _maxCount); - if (temp != _count) - { - OnChangeCount(); - } - } - } - - private int _count = 1; - - /// - /// 道具最大叠加用次数 - /// - public int MaxCount - { - get => _maxCount; - set - { - var temp = _maxCount; - _maxCount = Mathf.Max(1, value); - if (temp != _maxCount) - { - OnChangeMaxCount(); - } - - if (Count > _maxCount) - { - Count = _maxCount; - } - } - } - - private int _maxCount = 1; - - /// - /// 使用一次后的冷却时间, 单位: 秒 - /// - public float CooldownTime { get; set; } = 2f; - - /// - /// 当道具使用完后是否自动销毁 - /// - public bool AutoDestroy { get; set; } = false; - - /// - /// 道具充能进度, 必须要充能完成才能使用, 值范围: 0 - 1 - /// - public float ChargeProgress - { - get => _chargeProgress; - set - { - var temp = _chargeProgress; - _chargeProgress = Mathf.Clamp(value, 0, 1); - if (temp != _chargeProgress) - { - OnChangeChargeProgress(); - } - } - } - - private float _chargeProgress = 1; - - /// - /// 自动充能速度, 也就是每秒充能进度, 如果为0则表示不就行自动充能 - /// - public float AutoChargeSpeed { get; set; } - - //冷却计时器 - private float _cooldownTimer = 0; - - /// - /// 当检测是否可以使用时调用 - /// - public abstract bool OnCheckUse(); - - /// - /// 当道具被使用时调用, 函数返回值为消耗数量 - /// - protected abstract int OnUse(); - - /// - /// 道具数量改变时调用 - /// - protected virtual void OnChangeCount() - { - } - - /// - /// 道具最大数量改变时调用 - /// - protected virtual void OnChangeMaxCount() - { - } - - /// - /// 道具充能进度改变时调用 - /// - protected virtual void OnChangeChargeProgress() - { - } - - /// - /// 冷却完成时调用 - /// - protected virtual void OnCooldownFinish() - { - } - - protected override void Process(float delta) - { - RunUpdate(delta); - } - - public override void PackProcess(float delta) - { - RunUpdate(delta); - } - - private void RunUpdate(float delta) - { - if (CheckAutoDestroy()) - { - return; - } - //冷却 - if (_cooldownTimer > 0) - { - _cooldownTimer -= delta; - - //冷却完成 - if (_cooldownTimer <= 0) - { - _cooldownTimer = 0; - OnCooldownFinish(); - } - } - - //自动充能 - if (AutoChargeSpeed > 0 && ChargeProgress < 1) - { - ChargeProgress += AutoChargeSpeed * delta; - } - } - - //检测是否达到自动销毁的条件 - private bool CheckAutoDestroy() - { - if (Count == 0 && AutoDestroy) //用光了, 自动销毁 - { - if (Master != null) - { - Master.ActivePropsPack.RemoveItem(this); - } - Destroy(); - return true; - } - - return false; - } - - /// - /// 检测是否可以使用当前道具 - /// - public bool CheckUse() - { - return ChargeProgress >= 1 && _cooldownTimer <= 0 && Count > 0 && OnCheckUse(); - } - - /// - /// 触发使用道具 - /// - public void Use() - { - if (Master == null) - { - return; - } - if (CheckUse()) //可以使用道具 - { - var num = OnUse(); - if (num != 0) - { - Count -= num; - } - - //冷却计时器 - _cooldownTimer = CooldownTime; - } - } - - /// - /// 获取冷却进度 0 - 1 - /// - public float GetCooldownProgress() - { - if (_cooldownTimer <= 0) - { - return 1; - } - - return (CooldownTime - _cooldownTimer) / CooldownTime; - } - - public override void Interactive(ActivityObject master) - { - if (master is Player player) - { - if (player.ActivePropsPack.Capacity == 0) - { - //容量为0 - return; - } - var item = player.ActivePropsPack.GetItemById(ActivityBase.Id); - if (item == null) //没有同类型物体 - { - if (!player.ActivePropsPack.HasVacancy()) //没有空位置, 扔掉当前道具 - { - player.ThrowActiveProp(player.ActivePropsPack.ActiveIndex); - } - //替换手中的道具 - if (player.PickUpActiveProp(this)) - { - Pickup(); - } - } - else - { - //处理同类型道具 - if (Superposition && item.Count < item.MaxCount) //允许叠加 - { - if (item.Count + Count > item.MaxCount) - { - Count -= item.MaxCount - item.Count; - item.Count = item.MaxCount; - } - else - { - item.Count += Count; - Count = 0; - } - Destroy(); - } - } - } - } - - public override CheckInteractiveResult CheckInteractive(ActivityObject master) - { - if (master is Player player) - { - if (player.ActivePropsPack.Capacity == 0) - { - //容量为0 - return new CheckInteractiveResult(this); - } - //查找相同类型的道具 - var item = player.ActivePropsPack.GetItemById(ActivityBase.Id); - if (item == null) //没有同类型物体 - { - if (player.ActivePropsPack.HasVacancy()) //还有空位, 拾起道具 - { - return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.PickUp); - } - - //替换手中的道具 - return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Replace); - } - - //处理同类型道具 - if (Superposition && item.Count < item.MaxCount) //允许叠加 - { - return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Bullet); - } - - //该道具不能拾起 - return new CheckInteractiveResult(this); - } - - return new CheckInteractiveResult(this); - } - - public override void OnPickUpItem() - { - } - - public override void OnRemoveItem() - { - } - - public virtual void OnActiveItem() - { - } - - public virtual void OnConcealItem() - { - } - - public virtual void OnOverflowItem() - { - Master.ThrowActiveProp(PackageIndex); - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs index d5d5905..b7a454b 100644 --- a/DungeonShooting_Godot/src/game/activity/role/Role.cs +++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs @@ -54,12 +54,12 @@ /// /// 携带的被动道具列表 /// - public List BuffPropPack { get; } = new List(); + public List BuffPropPack { get; } = new List(); /// /// 携带的主动道具包裹 /// - public Package ActivePropsPack { get; private set; } + public Package ActivePropsPack { get; private set; } /// /// 互动碰撞区域 @@ -431,42 +431,42 @@ /// /// 当拾起某个主动道具时调用 /// - protected virtual void OnPickUpActiveProp(ActivePropActivity activePropActivity) + protected virtual void OnPickUpActiveProp(ActiveProp activeProp) { } /// /// 当移除某个主动道具时调用 /// - protected virtual void OnRemoveActiveProp(ActivePropActivity activePropActivity) + protected virtual void OnRemoveActiveProp(ActiveProp activeProp) { } /// /// 当切换到某个主动道具时调用 /// - protected virtual void OnExchangeActiveProp(ActivePropActivity activePropActivity) + protected virtual void OnExchangeActiveProp(ActiveProp activeProp) { } /// /// 当拾起某个被动道具时调用 /// - protected virtual void OnPickUpBuffProp(BuffActivity buffActivity) + protected virtual void OnPickUpBuffProp(BuffProp buffProp) { } /// /// 当移除某个被动道具时调用 /// - protected virtual void OnRemoveBuffProp(BuffActivity buffActivity) + protected virtual void OnRemoveBuffProp(BuffProp buffProp) { } public override void OnInit() { RoleState = OnCreateRoleState(); - ActivePropsPack = AddComponent>(); + ActivePropsPack = AddComponent>(); ActivePropsPack.SetCapacity(RoleState.CanPickUpWeapon ? 1 : 0); _startScale = Scale; @@ -617,7 +617,7 @@ var props = ActivePropsPack.ItemSlot; if (props.Length > 0) { - props = (ActivePropActivity[])props.Clone(); + props = (ActiveProp[])props.Clone(); foreach (var prop in props) { if (prop != null && !prop.IsDestroyed) @@ -673,15 +673,15 @@ /// /// 拾起主动道具, 返回是否成功拾起, 如果不想立刻切换到该道具, exchange 请传 false /// - /// 主动道具对象 + /// 主动道具对象 /// 是否立即切换到该道具, 默认 true - public bool PickUpActiveProp(ActivePropActivity activePropActivity, bool exchange = true) + public bool PickUpActiveProp(ActiveProp activeProp, bool exchange = true) { - if (ActivePropsPack.PickupItem(activePropActivity, exchange) != -1) + if (ActivePropsPack.PickupItem(activeProp, exchange) != -1) { //从可互动队列中移除 - InteractiveItemList.Remove(activePropActivity); - OnPickUpActiveProp(activePropActivity); + InteractiveItemList.Remove(activeProp); + OnPickUpActiveProp(activeProp); return true; } @@ -716,28 +716,28 @@ /// /// 拾起被动道具, 返回是否成功拾起 /// - /// 被动道具对象 - public bool PickUpBuffProp(BuffActivity buffActivity) + /// 被动道具对象 + public bool PickUpBuffProp(BuffProp buffProp) { - if (BuffPropPack.Contains(buffActivity)) + if (BuffPropPack.Contains(buffProp)) { Debug.LogError("被动道具已经在背包中了!"); return false; } - BuffPropPack.Add(buffActivity); - buffActivity.Master = this; - OnPickUpBuffProp(buffActivity); - buffActivity.OnPickUpItem(); + BuffPropPack.Add(buffProp); + buffProp.Master = this; + OnPickUpBuffProp(buffProp); + buffProp.OnPickUpItem(); return true; } /// /// 扔掉指定的被动道具 /// - /// - public void ThrowBuffProp(BuffActivity buffActivity) + /// + public void ThrowBuffProp(BuffProp buffProp) { - var index = BuffPropPack.IndexOf(buffActivity); + var index = BuffPropPack.IndexOf(buffProp); if (index < 0) { Debug.LogError("当前道具不在角色背包中!"); diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index f9669ae..6153367 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -354,24 +354,24 @@ UiManager.Open_Settlement(); } - protected override void OnPickUpActiveProp(ActivePropActivity activePropActivity) + protected override void OnPickUpActiveProp(ActiveProp activeProp) { - EventManager.EmitEvent(EventEnum.OnPlayerPickUpProp, activePropActivity); + EventManager.EmitEvent(EventEnum.OnPlayerPickUpProp, activeProp); } - protected override void OnRemoveActiveProp(ActivePropActivity activePropActivity) + protected override void OnRemoveActiveProp(ActiveProp activeProp) { - EventManager.EmitEvent(EventEnum.OnPlayerRemoveProp, activePropActivity); + EventManager.EmitEvent(EventEnum.OnPlayerRemoveProp, activeProp); } - protected override void OnPickUpBuffProp(BuffActivity buffActivity) + protected override void OnPickUpBuffProp(BuffProp buffProp) { - EventManager.EmitEvent(EventEnum.OnPlayerPickUpProp, buffActivity); + EventManager.EmitEvent(EventEnum.OnPlayerPickUpProp, buffProp); } - protected override void OnRemoveBuffProp(BuffActivity buffActivity) + protected override void OnRemoveBuffProp(BuffProp buffProp) { - EventManager.EmitEvent(EventEnum.OnPlayerRemoveProp, buffActivity); + EventManager.EmitEvent(EventEnum.OnPlayerRemoveProp, buffProp); } /// diff --git a/DungeonShooting_Godot/src/game/buff/BuffFragment.cs b/DungeonShooting_Godot/src/game/buff/BuffFragment.cs index 50c0727..16f6110 100644 --- a/DungeonShooting_Godot/src/game/buff/BuffFragment.cs +++ b/DungeonShooting_Godot/src/game/buff/BuffFragment.cs @@ -4,7 +4,7 @@ /// /// 被动属性逻辑基类 /// -public abstract partial class BuffFragment : Component +public abstract class BuffFragment : Component { /// /// 所属角色对象 diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_ActivePropsCapacity.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_ActivePropsCapacity.cs new file mode 100644 index 0000000..7163a9d --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_ActivePropsCapacity.cs @@ -0,0 +1,21 @@ + +[Buff("ActivePropsCapacity", "主动道具背包容量 buff, 参数‘1’为主动道具背包增加的容量")] +public class Buff_ActivePropsCapacity : BuffFragment +{ + private int _value; + + public override void InitParam(float arg1) + { + _value = (int)arg1; + } + + public override void OnPickUpItem() + { + Role.ActivePropsPack.SetCapacity(Role.ActivePropsPack.Capacity + _value); + } + + public override void OnRemoveItem() + { + Role.ActivePropsPack.SetCapacity(Role.ActivePropsPack.Capacity - _value); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletBounceCount.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletBounceCount.cs new file mode 100644 index 0000000..1f57944 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletBounceCount.cs @@ -0,0 +1,26 @@ + +[Buff("BulletBounceCount", "子弹弹射数量 buff, 参数‘1’为增加的弹射次数")] +public class Buff_BulletBounceCount : BuffFragment +{ + private int _value; + + public override void InitParam(float arg1) + { + _value = (int)arg1; + } + + public override void OnPickUpItem() + { + Role.RoleState.CalcBulletBounceCountEvent += CalcBulletBounceCountEvent; + } + + public override void OnRemoveItem() + { + Role.RoleState.CalcBulletBounceCountEvent -= CalcBulletBounceCountEvent; + } + + private void CalcBulletBounceCountEvent(int originBounce, RefValue bounce) + { + bounce.Value += _value; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletCount.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletCount.cs new file mode 100644 index 0000000..71b3cfd --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletCount.cs @@ -0,0 +1,52 @@ + +using Godot; + +[Buff("BulletCount", + "子弹数量 buff, " + + "参数‘1’为子弹数量添加类型, 1: 具体数量, 2:百分比(小数), " + + "参数‘2’为增加子弹的数量")] +public class Buff_BulletCount : BuffFragment +{ + private int _type; + private float _value; + + public override void InitParam(float arg1, float arg2) + { + _type = (int)arg1; + _value = (int)arg2; + } + + public override void OnPickUpItem() + { + if (_type == 1) + { + Role.RoleState.CalcBulletCountEvent += CalcBulletCountEvent1; + } + else + { + Role.RoleState.CalcBulletCountEvent += CalcBulletCountEvent2; + } + } + + public override void OnRemoveItem() + { + if (_type == 1) + { + Role.RoleState.CalcBulletCountEvent -= CalcBulletCountEvent1; + } + else + { + Role.RoleState.CalcBulletCountEvent -= CalcBulletCountEvent2; + } + } + + private void CalcBulletCountEvent1(int originCount, RefValue refValue) + { + 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/buff/Buff_BulletDeviationAngle.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDeviationAngle.cs new file mode 100644 index 0000000..2a7ecf8 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDeviationAngle.cs @@ -0,0 +1,31 @@ + +[Buff("BulletDeviationAngle", + "子弹偏移角度 buff, " + + "参数‘1’为增加子弹偏移角度下限, " + + "参数‘2’为增加子弹偏移角度上限, 单位角度制, 会从上限和下限随机抽取值")] +public class Buff_BulletDeviationAngle : BuffFragment +{ + private float _min; + private float _max; + + public override void InitParam(float arg1, float arg2) + { + _min = arg1; + _max = arg2; + } + + public override void OnPickUpItem() + { + Role.RoleState.CalcBulletDeviationAngleEvent += CalcBulletDeviationAngleEvent; + } + + public override void OnRemoveItem() + { + Role.RoleState.CalcBulletDeviationAngleEvent -= CalcBulletDeviationAngleEvent; + } + + private void CalcBulletDeviationAngleEvent(float originAngle, RefValue refValue) + { + refValue.Value += Utils.Random.RandomRangeFloat(_min, _max); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDistance.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDistance.cs new file mode 100644 index 0000000..b394049 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDistance.cs @@ -0,0 +1,50 @@ + +[Buff("BulletDistance", + "子弹射程 buff, " + + "参数‘1’为射程增加类型: 1:具体射程, 2:百分比射程(小数), " + + "参数‘2’为子弹增加的射程值")] +public class Buff_BulletDistance : 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.CalcBulletDistanceEvent += CalcBulletDistanceEvent1; + } + else + { + Role.RoleState.CalcBulletDistanceEvent += CalcBulletDistanceEvent2; + } + } + + public override void OnRemoveItem() + { + if (_type == 1) + { + Role.RoleState.CalcBulletDistanceEvent -= CalcBulletDistanceEvent1; + } + else + { + Role.RoleState.CalcBulletDistanceEvent -= CalcBulletDistanceEvent2; + } + } + + private void CalcBulletDistanceEvent1(float originDistance, RefValue distance) + { + distance.Value += _value; + } + + private void CalcBulletDistanceEvent2(float originDistance, RefValue distance) + { + distance.Value += originDistance * _value; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletPenetration.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletPenetration.cs new file mode 100644 index 0000000..89040fa --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletPenetration.cs @@ -0,0 +1,26 @@ + +[Buff("BulletPenetration", "子弹穿透次数 buff, 参数‘1’为增加的穿透次数")] +public class Buff_BulletPenetration : BuffFragment +{ + private int _value; + + public override void InitParam(float arg1) + { + _value = (int)arg1; + } + + public override void OnPickUpItem() + { + Role.RoleState.CalcBulletPenetrationEvent += CalcBulletPenetrationEvent; + } + + public override void OnRemoveItem() + { + Role.RoleState.CalcBulletPenetrationEvent -= CalcBulletPenetrationEvent; + } + + private void CalcBulletPenetrationEvent(int origin, RefValue penetration) + { + penetration.Value += _value; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletRepel.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletRepel.cs new file mode 100644 index 0000000..51e7ca7 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletRepel.cs @@ -0,0 +1,67 @@ + +using Godot; + +[Buff("BulletRepel", + "子弹击退 buff, " + + "参数‘1’为击退增加类型: 1:具体击退值, 2:百分比击退值(小数), " + + "参数‘2’为子弹增加的击退值")] +public class Buff_BulletRepel : 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.CalcBulletRepelEvent += CalcBulletRepelEvent1; + } + else + { + Role.RoleState.CalcBulletRepelEvent += CalcBulletRepelEvent2; + } + } + + public override void OnRemoveItem() + { + if (_type == 1) + { + Role.RoleState.CalcBulletRepelEvent -= CalcBulletRepelEvent1; + } + else + { + Role.RoleState.CalcBulletRepelEvent -= CalcBulletRepelEvent2; + } + } + + private void CalcBulletRepelEvent1(float originRepel, RefValue repel) + { + if (Role.WeaponPack.ActiveItem != null && Role.WeaponPack.ActiveItem.Attribute.IsMelee) + { + return; + } + repel.Value += _value; + } + + private void CalcBulletRepelEvent2(float originRepel, RefValue repel) + { + if (Role.WeaponPack.ActiveItem != null && Role.WeaponPack.ActiveItem.Attribute.IsMelee) + { + return; + } + + 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/buff/Buff_BulletSpeed.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletSpeed.cs new file mode 100644 index 0000000..b438e39 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletSpeed.cs @@ -0,0 +1,50 @@ + +[Buff("BulletSpeed", + "子弹速度 buff, " + + "参数‘1’为射速增加类型: 1:具体射速, 2:百分比射速(小数), " + + "参数‘2’为子弹增加的射速值")] +public class Buff_BulletSpeed : 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.CalcBulletSpeedEvent += CalcBulletSpeedEvent1; + } + else + { + Role.RoleState.CalcBulletSpeedEvent += CalcBulletSpeedEvent2; + } + } + + public override void OnRemoveItem() + { + if (_type == 1) + { + Role.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent1; + } + else + { + Role.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent2; + } + } + + private void CalcBulletSpeedEvent1(float originSpeed, RefValue speed) + { + speed.Value += _value; + } + + private void CalcBulletSpeedEvent2(float originSpeed, RefValue speed) + { + speed.Value += originSpeed * _value; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_Damage.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_Damage.cs new file mode 100644 index 0000000..e5eb3c6 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_Damage.cs @@ -0,0 +1,59 @@ + +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 new file mode 100644 index 0000000..bb6fea6 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxHp.cs @@ -0,0 +1,30 @@ + +using System.Collections.Generic; + +[Buff("MaxHp", "血量上限 buff, 参数‘1’为血量上限值")] +public class Buff_MaxHp : BuffFragment +{ + private List _cacheId = new List(); + private int _maxHp; + + public override void InitParam(float arg1) + { + _maxHp = (int)arg1; + } + + public override void OnPickUpItem() + { + Role.MaxHp += _maxHp; + var instanceId = Role.GetInstanceId(); + if (!_cacheId.Contains(instanceId)) + { + _cacheId.Add(instanceId); + Role.Hp += _maxHp; + } + } + + public override void OnRemoveItem() + { + Role.MaxHp -= _maxHp; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxShield.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxShield.cs new file mode 100644 index 0000000..c63c816 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxShield.cs @@ -0,0 +1,30 @@ + +using System.Collections.Generic; + +[Buff("MaxShield", "护盾上限buff, 参数‘1’为护盾上限")] +public class Buff_MaxShield : BuffFragment +{ + private List _cacheId = new List(); + private int _maxShield; + + public override void InitParam(float arg1) + { + _maxShield = (int)arg1; + } + + public override void OnPickUpItem() + { + Role.MaxShield += _maxShield; + var instanceId = Role.GetInstanceId(); + if (!_cacheId.Contains(instanceId)) + { + _cacheId.Add(instanceId); + Role.Shield += _maxShield; + } + } + + public override void OnRemoveItem() + { + Role.MaxShield -= _maxShield; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_MoveSpeed.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_MoveSpeed.cs new file mode 100644 index 0000000..880ef7f --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_MoveSpeed.cs @@ -0,0 +1,25 @@ + +[Buff("MoveSpeed", "移速 buff, 参数‘1’为移动速度值")] +public class Buff_MoveSpeed : BuffFragment +{ + private float _moveSpeed; + + public override void InitParam(float arg1) + { + _moveSpeed = arg1; + } + + public override void OnPickUpItem() + { + Role.RoleState.MoveSpeed += _moveSpeed; + Role.RoleState.Acceleration += _moveSpeed * 1.4f; + Role.RoleState.Friction += _moveSpeed * 10; + } + + public override void OnRemoveItem() + { + Role.RoleState.MoveSpeed -= _moveSpeed; + Role.RoleState.Acceleration -= _moveSpeed * 1.4f; + Role.RoleState.Friction -= _moveSpeed * 10; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_OffsetInjury.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_OffsetInjury.cs new file mode 100644 index 0000000..c617952 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_OffsetInjury.cs @@ -0,0 +1,29 @@ + +[Buff("OffsetInjury", "受伤时有概率抵消伤害的buff, 参数‘1’为抵消伤害概率百分比(小数)")] +public class Buff_OffsetInjury : BuffFragment +{ + private float _value; + + public override void InitParam(float arg1) + { + _value = arg1; + } + + public override void OnPickUpItem() + { + Role.RoleState.CalcHurtDamageEvent += CalcHurtDamageEvent; + } + + public override void OnRemoveItem() + { + Role.RoleState.CalcHurtDamageEvent -= CalcHurtDamageEvent; + } + + private void CalcHurtDamageEvent(int originDamage, RefValue refValue) + { + if (refValue.Value > 0 && Utils.Random.RandomBoolean(_value)) + { + refValue.Value = 0; + } + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_RandomBulletSpeed.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_RandomBulletSpeed.cs new file mode 100644 index 0000000..d70518d --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_RandomBulletSpeed.cs @@ -0,0 +1,31 @@ + +[Buff("RandomBulletSpeed", + "子弹增加随机速度 buff, " + + "参数‘1’为增加子弹速度下限, " + + "参数‘2’为增加子弹速度上限, 会从上限和下限随机抽取值")] +public class Buff_RandomBulletSpeed : BuffFragment +{ + private float _min; + private float _max; + + public override void InitParam(float arg1, float arg2) + { + _min = arg1; + _max = arg2; + } + + public override void OnPickUpItem() + { + Role.RoleState.CalcBulletSpeedEvent += CalcBulletSpeedEvent; + } + + public override void OnRemoveItem() + { + Role.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent; + } + + private void CalcBulletSpeedEvent(float originSpeed, RefValue speed) + { + speed.Value += originSpeed * Utils.Random.RandomRangeFloat(_min, _max); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_Scattering.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_Scattering.cs new file mode 100644 index 0000000..00fdc81 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_Scattering.cs @@ -0,0 +1,35 @@ + +using Godot; + +[Buff("Scattering", "提高武器精准度buff, 参数‘1’为提升的精准度百分比值(小数)")] +public class Buff_Scattering : BuffFragment +{ + private float _value; + + public override void InitParam(float arg1) + { + _value = arg1; + } + + public override void OnPickUpItem() + { + Role.RoleState.CalcStartScatteringEvent += CalcStartScatteringEvent; + Role.RoleState.CalcFinalScatteringEvent += CalcFinalScatteringEvent; + } + + public override void OnRemoveItem() + { + Role.RoleState.CalcStartScatteringEvent -= CalcStartScatteringEvent; + Role.RoleState.CalcFinalScatteringEvent -= CalcFinalScatteringEvent; + } + + private void CalcStartScatteringEvent(float originValue, RefValue refValue) + { + refValue.Value = Mathf.Max(0, refValue.Value - refValue.Value * _value); + } + + private void CalcFinalScatteringEvent(float originValue, RefValue refValue) + { + refValue.Value = Mathf.Max(0, refValue.Value - refValue.Value * _value); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_ShieldRecoveryTime.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_ShieldRecoveryTime.cs new file mode 100644 index 0000000..a70d11a --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_ShieldRecoveryTime.cs @@ -0,0 +1,21 @@ + +[Buff("ShieldRecoveryTime", "单格护盾减少的恢复时间, 参数‘1’单位: 秒")] +public class Buff_ShieldRecoveryTime : BuffFragment +{ + private float _time; + + public override void InitParam(float arg1) + { + _time = arg1; + } + + public override void OnPickUpItem() + { + Role.RoleState.ShieldRecoveryTime -= _time; + } + + public override void OnRemoveItem() + { + Role.RoleState.ShieldRecoveryTime += _time; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_WeaponCapacity.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_WeaponCapacity.cs new file mode 100644 index 0000000..fd7ef35 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_WeaponCapacity.cs @@ -0,0 +1,21 @@ + +[Buff("WeaponCapacity", "武器背包容量 buff, 参数‘1’为武器背包增加的容量")] +public class Buff_WeaponCapacity : BuffFragment +{ + private int _value; + + public override void InitParam(float arg1) + { + _value = (int)arg1; + } + + public override void OnPickUpItem() + { + Role.WeaponPack.SetCapacity(Role.WeaponPack.Capacity + _value); + } + + public override void OnRemoveItem() + { + Role.WeaponPack.SetCapacity(Role.WeaponPack.Capacity - _value); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_WoundedInvincibleTime.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_WoundedInvincibleTime.cs new file mode 100644 index 0000000..f7184ab --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_WoundedInvincibleTime.cs @@ -0,0 +1,21 @@ + +[Buff("WoundedInvincibleTime", "延长无敌时间buff, 参数‘1’为延长时间, 单位秒")] +public class Buff_WoundedInvincibleTime : BuffFragment +{ + private float _time; + + public override void InitParam(float arg1) + { + _time = arg1; + } + + public override void OnPickUpItem() + { + Role.RoleState.WoundedInvincibleTime += _time; + } + + public override void OnRemoveItem() + { + Role.RoleState.WoundedInvincibleTime -= _time; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_ActivePropsCapacity.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_ActivePropsCapacity.cs deleted file mode 100644 index 7163a9d..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_ActivePropsCapacity.cs +++ /dev/null @@ -1,21 +0,0 @@ - -[Buff("ActivePropsCapacity", "主动道具背包容量 buff, 参数‘1’为主动道具背包增加的容量")] -public class Buff_ActivePropsCapacity : BuffFragment -{ - private int _value; - - public override void InitParam(float arg1) - { - _value = (int)arg1; - } - - public override void OnPickUpItem() - { - Role.ActivePropsPack.SetCapacity(Role.ActivePropsPack.Capacity + _value); - } - - public override void OnRemoveItem() - { - Role.ActivePropsPack.SetCapacity(Role.ActivePropsPack.Capacity - _value); - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletBounceCount.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletBounceCount.cs deleted file mode 100644 index 1f57944..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletBounceCount.cs +++ /dev/null @@ -1,26 +0,0 @@ - -[Buff("BulletBounceCount", "子弹弹射数量 buff, 参数‘1’为增加的弹射次数")] -public class Buff_BulletBounceCount : BuffFragment -{ - private int _value; - - public override void InitParam(float arg1) - { - _value = (int)arg1; - } - - public override void OnPickUpItem() - { - Role.RoleState.CalcBulletBounceCountEvent += CalcBulletBounceCountEvent; - } - - public override void OnRemoveItem() - { - Role.RoleState.CalcBulletBounceCountEvent -= CalcBulletBounceCountEvent; - } - - private void CalcBulletBounceCountEvent(int originBounce, RefValue bounce) - { - bounce.Value += _value; - } -} \ 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 deleted file mode 100644 index 71b3cfd..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletCount.cs +++ /dev/null @@ -1,52 +0,0 @@ - -using Godot; - -[Buff("BulletCount", - "子弹数量 buff, " + - "参数‘1’为子弹数量添加类型, 1: 具体数量, 2:百分比(小数), " + - "参数‘2’为增加子弹的数量")] -public class Buff_BulletCount : BuffFragment -{ - private int _type; - private float _value; - - public override void InitParam(float arg1, float arg2) - { - _type = (int)arg1; - _value = (int)arg2; - } - - public override void OnPickUpItem() - { - if (_type == 1) - { - Role.RoleState.CalcBulletCountEvent += CalcBulletCountEvent1; - } - else - { - Role.RoleState.CalcBulletCountEvent += CalcBulletCountEvent2; - } - } - - public override void OnRemoveItem() - { - if (_type == 1) - { - Role.RoleState.CalcBulletCountEvent -= CalcBulletCountEvent1; - } - else - { - Role.RoleState.CalcBulletCountEvent -= CalcBulletCountEvent2; - } - } - - private void CalcBulletCountEvent1(int originCount, RefValue refValue) - { - 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_BulletDeviationAngle.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletDeviationAngle.cs deleted file mode 100644 index 2a7ecf8..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletDeviationAngle.cs +++ /dev/null @@ -1,31 +0,0 @@ - -[Buff("BulletDeviationAngle", - "子弹偏移角度 buff, " + - "参数‘1’为增加子弹偏移角度下限, " + - "参数‘2’为增加子弹偏移角度上限, 单位角度制, 会从上限和下限随机抽取值")] -public class Buff_BulletDeviationAngle : BuffFragment -{ - private float _min; - private float _max; - - public override void InitParam(float arg1, float arg2) - { - _min = arg1; - _max = arg2; - } - - public override void OnPickUpItem() - { - Role.RoleState.CalcBulletDeviationAngleEvent += CalcBulletDeviationAngleEvent; - } - - public override void OnRemoveItem() - { - Role.RoleState.CalcBulletDeviationAngleEvent -= CalcBulletDeviationAngleEvent; - } - - private void CalcBulletDeviationAngleEvent(float originAngle, RefValue refValue) - { - refValue.Value += Utils.Random.RandomRangeFloat(_min, _max); - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletDistance.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletDistance.cs deleted file mode 100644 index b394049..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletDistance.cs +++ /dev/null @@ -1,50 +0,0 @@ - -[Buff("BulletDistance", - "子弹射程 buff, " + - "参数‘1’为射程增加类型: 1:具体射程, 2:百分比射程(小数), " + - "参数‘2’为子弹增加的射程值")] -public class Buff_BulletDistance : 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.CalcBulletDistanceEvent += CalcBulletDistanceEvent1; - } - else - { - Role.RoleState.CalcBulletDistanceEvent += CalcBulletDistanceEvent2; - } - } - - public override void OnRemoveItem() - { - if (_type == 1) - { - Role.RoleState.CalcBulletDistanceEvent -= CalcBulletDistanceEvent1; - } - else - { - Role.RoleState.CalcBulletDistanceEvent -= CalcBulletDistanceEvent2; - } - } - - private void CalcBulletDistanceEvent1(float originDistance, RefValue distance) - { - distance.Value += _value; - } - - private void CalcBulletDistanceEvent2(float originDistance, RefValue distance) - { - distance.Value += originDistance * _value; - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletPenetration.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletPenetration.cs deleted file mode 100644 index 89040fa..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletPenetration.cs +++ /dev/null @@ -1,26 +0,0 @@ - -[Buff("BulletPenetration", "子弹穿透次数 buff, 参数‘1’为增加的穿透次数")] -public class Buff_BulletPenetration : BuffFragment -{ - private int _value; - - public override void InitParam(float arg1) - { - _value = (int)arg1; - } - - public override void OnPickUpItem() - { - Role.RoleState.CalcBulletPenetrationEvent += CalcBulletPenetrationEvent; - } - - public override void OnRemoveItem() - { - Role.RoleState.CalcBulletPenetrationEvent -= CalcBulletPenetrationEvent; - } - - private void CalcBulletPenetrationEvent(int origin, RefValue penetration) - { - penetration.Value += _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 deleted file mode 100644 index 51e7ca7..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletRepel.cs +++ /dev/null @@ -1,67 +0,0 @@ - -using Godot; - -[Buff("BulletRepel", - "子弹击退 buff, " + - "参数‘1’为击退增加类型: 1:具体击退值, 2:百分比击退值(小数), " + - "参数‘2’为子弹增加的击退值")] -public class Buff_BulletRepel : 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.CalcBulletRepelEvent += CalcBulletRepelEvent1; - } - else - { - Role.RoleState.CalcBulletRepelEvent += CalcBulletRepelEvent2; - } - } - - public override void OnRemoveItem() - { - if (_type == 1) - { - Role.RoleState.CalcBulletRepelEvent -= CalcBulletRepelEvent1; - } - else - { - Role.RoleState.CalcBulletRepelEvent -= CalcBulletRepelEvent2; - } - } - - private void CalcBulletRepelEvent1(float originRepel, RefValue repel) - { - if (Role.WeaponPack.ActiveItem != null && Role.WeaponPack.ActiveItem.Attribute.IsMelee) - { - return; - } - repel.Value += _value; - } - - private void CalcBulletRepelEvent2(float originRepel, RefValue repel) - { - if (Role.WeaponPack.ActiveItem != null && Role.WeaponPack.ActiveItem.Attribute.IsMelee) - { - return; - } - - 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 deleted file mode 100644 index b438e39..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletSpeed.cs +++ /dev/null @@ -1,50 +0,0 @@ - -[Buff("BulletSpeed", - "子弹速度 buff, " + - "参数‘1’为射速增加类型: 1:具体射速, 2:百分比射速(小数), " + - "参数‘2’为子弹增加的射速值")] -public class Buff_BulletSpeed : 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.CalcBulletSpeedEvent += CalcBulletSpeedEvent1; - } - else - { - Role.RoleState.CalcBulletSpeedEvent += CalcBulletSpeedEvent2; - } - } - - public override void OnRemoveItem() - { - if (_type == 1) - { - Role.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent1; - } - else - { - Role.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent2; - } - } - - private void CalcBulletSpeedEvent1(float originSpeed, RefValue speed) - { - speed.Value += _value; - } - - private void CalcBulletSpeedEvent2(float originSpeed, RefValue speed) - { - speed.Value += originSpeed * _value; - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_Damage.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_Damage.cs deleted file mode 100644 index e5eb3c6..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/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/fragment/Buff_MaxHp.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_MaxHp.cs deleted file mode 100644 index bb6fea6..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_MaxHp.cs +++ /dev/null @@ -1,30 +0,0 @@ - -using System.Collections.Generic; - -[Buff("MaxHp", "血量上限 buff, 参数‘1’为血量上限值")] -public class Buff_MaxHp : BuffFragment -{ - private List _cacheId = new List(); - private int _maxHp; - - public override void InitParam(float arg1) - { - _maxHp = (int)arg1; - } - - public override void OnPickUpItem() - { - Role.MaxHp += _maxHp; - var instanceId = Role.GetInstanceId(); - if (!_cacheId.Contains(instanceId)) - { - _cacheId.Add(instanceId); - Role.Hp += _maxHp; - } - } - - public override void OnRemoveItem() - { - Role.MaxHp -= _maxHp; - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_MaxShield.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_MaxShield.cs deleted file mode 100644 index c63c816..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_MaxShield.cs +++ /dev/null @@ -1,30 +0,0 @@ - -using System.Collections.Generic; - -[Buff("MaxShield", "护盾上限buff, 参数‘1’为护盾上限")] -public class Buff_MaxShield : BuffFragment -{ - private List _cacheId = new List(); - private int _maxShield; - - public override void InitParam(float arg1) - { - _maxShield = (int)arg1; - } - - public override void OnPickUpItem() - { - Role.MaxShield += _maxShield; - var instanceId = Role.GetInstanceId(); - if (!_cacheId.Contains(instanceId)) - { - _cacheId.Add(instanceId); - Role.Shield += _maxShield; - } - } - - public override void OnRemoveItem() - { - Role.MaxShield -= _maxShield; - } -} \ 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 deleted file mode 100644 index 880ef7f..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_MoveSpeed.cs +++ /dev/null @@ -1,25 +0,0 @@ - -[Buff("MoveSpeed", "移速 buff, 参数‘1’为移动速度值")] -public class Buff_MoveSpeed : BuffFragment -{ - private float _moveSpeed; - - public override void InitParam(float arg1) - { - _moveSpeed = arg1; - } - - public override void OnPickUpItem() - { - Role.RoleState.MoveSpeed += _moveSpeed; - Role.RoleState.Acceleration += _moveSpeed * 1.4f; - Role.RoleState.Friction += _moveSpeed * 10; - } - - public override void OnRemoveItem() - { - Role.RoleState.MoveSpeed -= _moveSpeed; - Role.RoleState.Acceleration -= _moveSpeed * 1.4f; - Role.RoleState.Friction -= _moveSpeed * 10; - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_OffsetInjury.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_OffsetInjury.cs deleted file mode 100644 index c617952..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_OffsetInjury.cs +++ /dev/null @@ -1,29 +0,0 @@ - -[Buff("OffsetInjury", "受伤时有概率抵消伤害的buff, 参数‘1’为抵消伤害概率百分比(小数)")] -public class Buff_OffsetInjury : BuffFragment -{ - private float _value; - - public override void InitParam(float arg1) - { - _value = arg1; - } - - public override void OnPickUpItem() - { - Role.RoleState.CalcHurtDamageEvent += CalcHurtDamageEvent; - } - - public override void OnRemoveItem() - { - Role.RoleState.CalcHurtDamageEvent -= CalcHurtDamageEvent; - } - - private void CalcHurtDamageEvent(int originDamage, RefValue refValue) - { - if (refValue.Value > 0 && Utils.Random.RandomBoolean(_value)) - { - refValue.Value = 0; - } - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_RandomBulletSpeed.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_RandomBulletSpeed.cs deleted file mode 100644 index d70518d..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_RandomBulletSpeed.cs +++ /dev/null @@ -1,31 +0,0 @@ - -[Buff("RandomBulletSpeed", - "子弹增加随机速度 buff, " + - "参数‘1’为增加子弹速度下限, " + - "参数‘2’为增加子弹速度上限, 会从上限和下限随机抽取值")] -public class Buff_RandomBulletSpeed : BuffFragment -{ - private float _min; - private float _max; - - public override void InitParam(float arg1, float arg2) - { - _min = arg1; - _max = arg2; - } - - public override void OnPickUpItem() - { - Role.RoleState.CalcBulletSpeedEvent += CalcBulletSpeedEvent; - } - - public override void OnRemoveItem() - { - Role.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent; - } - - private void CalcBulletSpeedEvent(float originSpeed, RefValue speed) - { - speed.Value += originSpeed * Utils.Random.RandomRangeFloat(_min, _max); - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_Scattering.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_Scattering.cs deleted file mode 100644 index 00fdc81..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_Scattering.cs +++ /dev/null @@ -1,35 +0,0 @@ - -using Godot; - -[Buff("Scattering", "提高武器精准度buff, 参数‘1’为提升的精准度百分比值(小数)")] -public class Buff_Scattering : BuffFragment -{ - private float _value; - - public override void InitParam(float arg1) - { - _value = arg1; - } - - public override void OnPickUpItem() - { - Role.RoleState.CalcStartScatteringEvent += CalcStartScatteringEvent; - Role.RoleState.CalcFinalScatteringEvent += CalcFinalScatteringEvent; - } - - public override void OnRemoveItem() - { - Role.RoleState.CalcStartScatteringEvent -= CalcStartScatteringEvent; - Role.RoleState.CalcFinalScatteringEvent -= CalcFinalScatteringEvent; - } - - private void CalcStartScatteringEvent(float originValue, RefValue refValue) - { - refValue.Value = Mathf.Max(0, refValue.Value - refValue.Value * _value); - } - - private void CalcFinalScatteringEvent(float originValue, RefValue refValue) - { - refValue.Value = Mathf.Max(0, refValue.Value - refValue.Value * _value); - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_ShieldRecoveryTime.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_ShieldRecoveryTime.cs deleted file mode 100644 index a70d11a..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_ShieldRecoveryTime.cs +++ /dev/null @@ -1,21 +0,0 @@ - -[Buff("ShieldRecoveryTime", "单格护盾减少的恢复时间, 参数‘1’单位: 秒")] -public class Buff_ShieldRecoveryTime : BuffFragment -{ - private float _time; - - public override void InitParam(float arg1) - { - _time = arg1; - } - - public override void OnPickUpItem() - { - Role.RoleState.ShieldRecoveryTime -= _time; - } - - public override void OnRemoveItem() - { - Role.RoleState.ShieldRecoveryTime += _time; - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_WeaponCapacity.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_WeaponCapacity.cs deleted file mode 100644 index fd7ef35..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_WeaponCapacity.cs +++ /dev/null @@ -1,21 +0,0 @@ - -[Buff("WeaponCapacity", "武器背包容量 buff, 参数‘1’为武器背包增加的容量")] -public class Buff_WeaponCapacity : BuffFragment -{ - private int _value; - - public override void InitParam(float arg1) - { - _value = (int)arg1; - } - - public override void OnPickUpItem() - { - Role.WeaponPack.SetCapacity(Role.WeaponPack.Capacity + _value); - } - - public override void OnRemoveItem() - { - Role.WeaponPack.SetCapacity(Role.WeaponPack.Capacity - _value); - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_WoundedInvincibleTime.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_WoundedInvincibleTime.cs deleted file mode 100644 index f7184ab..0000000 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_WoundedInvincibleTime.cs +++ /dev/null @@ -1,21 +0,0 @@ - -[Buff("WoundedInvincibleTime", "延长无敌时间buff, 参数‘1’为延长时间, 单位秒")] -public class Buff_WoundedInvincibleTime : BuffFragment -{ - private float _time; - - public override void InitParam(float arg1) - { - _time = arg1; - } - - public override void OnPickUpItem() - { - Role.RoleState.WoundedInvincibleTime += _time; - } - - public override void OnRemoveItem() - { - Role.RoleState.WoundedInvincibleTime -= _time; - } -} \ No newline at end of file