Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / prop / buff / Buff0007.cs
@小李xl 小李xl on 29 Jun 2023 614 bytes 制作被动道具
  1.  
  2. using Godot;
  3.  
  4. /// <summary>
  5. /// 受伤时有15%概率抵消伤害
  6. /// </summary>
  7. [GlobalClass, Tool]
  8. public partial class Buff0007 : Buff
  9. {
  10. protected override void OnPickUp(Role master)
  11. {
  12. master.RoleState.CalcHurtDamageEvent += CalcHurtDamageEvent;
  13. }
  14.  
  15. protected override void OnRemove(Role master)
  16. {
  17. master.RoleState.CalcHurtDamageEvent -= CalcHurtDamageEvent;
  18. }
  19.  
  20. private void CalcHurtDamageEvent(int originDamage, RefValue<int> refValue)
  21. {
  22. if (refValue.Value > 0 && Utils.RandomBoolean(0.15f))
  23. {
  24. refValue.Value = 0;
  25. }
  26. }
  27. }