diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletDistance.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletDistance.cs new file mode 100644 index 0000000..0739ebc --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletDistance.cs @@ -0,0 +1,50 @@ + +/// <summary> +/// 子弹射程 buff +/// </summary> +[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<float> distance) + { + distance.Value += _value; + } + + private void CalcBulletDistanceEvent2(float originDistance, RefValue<float> distance) + { + distance.Value += originDistance * _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 new file mode 100644 index 0000000..a9adb10 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_BulletSpeed.cs @@ -0,0 +1,50 @@ + +/// <summary> +/// 子弹速度 buff +/// </summary> +[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<float> speed) + { + speed.Value += _value; + } + + private void CalcBulletSpeedEvent2(float originSpeed, RefValue<float> 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 new file mode 100644 index 0000000..65933f7 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_Damage.cs @@ -0,0 +1,52 @@ + +using Godot; + +/// <summary> +/// 提升伤害buff +/// </summary> +[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<int> refValue) + { + refValue.Value += Mathf.CeilToInt(_value); + } + + private void CalcDamage2(int originDamage, RefValue<int> refValue) + { + refValue.Value += Mathf.CeilToInt(originDamage * _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 new file mode 100644 index 0000000..0b7a645 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_MaxHp.cs @@ -0,0 +1,33 @@ + +using System.Collections.Generic; + +/// <summary> +/// 血量上限 buff +/// </summary> +[Buff("MaxHp", "血量上限 buff, 参数‘1’为血量上限值")] +public class Buff_MaxHp : BuffFragment +{ + private List<ulong> _cacheId = new List<ulong>(); + 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 new file mode 100644 index 0000000..e93f301 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_MaxShield.cs @@ -0,0 +1,33 @@ + +using System.Collections.Generic; + +/// <summary> +/// 护盾上限buff +/// </summary> +[Buff("MaxShield", "护盾上限buff, 参数‘1’为护盾上限")] +public class Buff_MaxShield : BuffFragment +{ + private List<ulong> _cacheId = new List<ulong>(); + 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 index 8003172..96419d1 100644 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_MoveSpeed.cs +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_MoveSpeed.cs @@ -2,7 +2,7 @@ /// <summary> /// 移速 buff /// </summary> -[Buff("MoveSpeed", "移速 buff, 参数 1 为移动速度值")] +[Buff("MoveSpeed", "移速 buff, 参数‘1’为移动速度值")] public class Buff_MoveSpeed : BuffFragment { private float _moveSpeed; diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_OffsetInjury.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_OffsetInjury.cs new file mode 100644 index 0000000..40679bc --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_OffsetInjury.cs @@ -0,0 +1,32 @@ + +/// <summary> +/// 受伤时有概率抵消伤害的buff +/// </summary> +[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<int> 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_Scattering.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_Scattering.cs new file mode 100644 index 0000000..387309a --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_Scattering.cs @@ -0,0 +1,36 @@ + +/// <summary> +/// 提高武器精准度buff +/// </summary> +[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<float> refValue) + { + refValue.Value -= refValue.Value * _value; + } + + private void CalcFinalScatteringEvent(float originValue, RefValue<float> refValue) + { + 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 new file mode 100644 index 0000000..078e887 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_ShieldRecoveryTime.cs @@ -0,0 +1,24 @@ + +/// <summary> +/// 护盾恢复时间buff +/// </summary> +[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_WoundedInvincibleTime.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_WoundedInvincibleTime.cs new file mode 100644 index 0000000..b79cf70 --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_WoundedInvincibleTime.cs @@ -0,0 +1,24 @@ + +/// <summary> +/// 延长无敌时间buff +/// </summary> +[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