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