Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / buff / condition / Cond_Hp.cs
@小李xl 小李xl on 21 Mar 2024 850 bytes 新增3个道具
  1. using System.Text.Json;
  2.  
  3. [ConditionFragment("Hp",
  4. "判断血量, " +
  5. "参数1为判断条件符号, 分别为: >, <, =, >=, <=; " +
  6. "参数2为比较的值")]
  7. public class Cond_Hp : ConditionFragment
  8. {
  9. private string _symbol;
  10. private int _value;
  11. public override void InitParam(JsonElement[] args)
  12. {
  13. _symbol = args[0].GetString();
  14. _value = args[1].GetInt32();
  15. }
  16.  
  17. public override bool OnCheckUse()
  18. {
  19. switch (_symbol)
  20. {
  21. case ">":
  22. return Role.Hp > _value;
  23. case "<":
  24. return Role.Hp < _value;
  25. case "=":
  26. return Role.Hp == _value;
  27. case ">=":
  28. return Role.Hp >= _value;
  29. case "<=":
  30. return Role.Hp <= _value;
  31. }
  32.  
  33. return false;
  34. }
  35. }