Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / buff / fragment / Buff_BulletCount.cs
@小李xl 小李xl on 15 Mar 2024 1 KB buff系统重构中
  1.  
  2. using Godot;
  3.  
  4. [Buff("BulletCount",
  5. "子弹数量 buff, " +
  6. "参数‘1’为子弹数量添加类型, 1: 具体数量, 2:百分比(小数), " +
  7. "参数‘2’为增加子弹的数量")]
  8. public class Buff_BulletCount : BuffFragment
  9. {
  10. private int _type;
  11. private float _value;
  12.  
  13. public override void InitParam(float arg1, float arg2)
  14. {
  15. _type = (int)arg1;
  16. _value = (int)arg2;
  17. }
  18. public override void OnPickUpItem()
  19. {
  20. if (_type == 1)
  21. {
  22. Role.RoleState.CalcBulletCountEvent += CalcBulletCountEvent1;
  23. }
  24. else
  25. {
  26. Role.RoleState.CalcBulletCountEvent += CalcBulletCountEvent2;
  27. }
  28. }
  29.  
  30. public override void OnRemoveItem()
  31. {
  32. if (_type == 1)
  33. {
  34. Role.RoleState.CalcBulletCountEvent -= CalcBulletCountEvent1;
  35. }
  36. else
  37. {
  38. Role.RoleState.CalcBulletCountEvent -= CalcBulletCountEvent2;
  39. }
  40. }
  41.  
  42. private void CalcBulletCountEvent1(int originCount, RefValue<int> refValue)
  43. {
  44. refValue.Value += Mathf.CeilToInt(_value);
  45. }
  46. private void CalcBulletCountEvent2(int originCount, RefValue<int> refValue)
  47. {
  48. refValue.Value += Mathf.CeilToInt(originCount * _value);
  49. }
  50. }