Triggers.Items.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using CommonLang.Property;
  5. using CommonAI.Zone.ZoneEditor;
  6. using CommonAI.Zone.Instance;
  7. using CommonAI.Zone.Attributes;
  8. using CommonAI.Zone.EventTrigger;
  9. namespace CommonAI.Zone.ZoneEditor.EventTrigger
  10. {
  11. [DescAttribute("某个道具添加到场景", "道具")]
  12. public class AddedItem : AbstractTrigger
  13. {
  14. public override string ToString()
  15. {
  16. return string.Format("当某个道具添加到场景");
  17. }
  18. public override void Listen(EventTriggerAdapter api, EventArguments args)
  19. {
  20. api.listen_ItemAdded(args, api.ZoneAPI);
  21. }
  22. }
  23. [DescAttribute("某个单位开始检取特定道具", "道具")]
  24. public class TryUnitPickItem : AbstractTrigger
  25. {
  26. [DescAttribute("道具")]
  27. public ItemValue Item = new ItemValue.NA();
  28. [DescAttribute("是否可以检取")]
  29. public BooleanValue Condition = new BooleanValue.BooleanComparison();
  30. public override string ToString()
  31. {
  32. return string.Format("当单位开始检取{0}", Item);
  33. }
  34. public override void Listen(EventTriggerAdapter api, EventArguments args)
  35. {
  36. api.listen_TryPickItem(args, api.ZoneAPI, (zone, unit, item) =>
  37. {
  38. InstanceItem ditem = Item.GetValue(api, args);
  39. if (ditem != null && ditem == item)
  40. {
  41. bool ret = Condition.GetValue(api, args);
  42. return ret;
  43. }
  44. return true;
  45. });
  46. }
  47. }
  48. [DescAttribute("某个单位开始检取某个道具", "道具")]
  49. public class TryUnitPickAnyItem : AbstractTrigger
  50. {
  51. [DescAttribute("是否可以检取")]
  52. public BooleanValue Condition = new BooleanValue.BooleanComparison();
  53. public override string ToString()
  54. {
  55. return string.Format("当单位开始检取道具");
  56. }
  57. public override void Listen(EventTriggerAdapter api, EventArguments args)
  58. {
  59. api.listen_TryPickItem(args, api.ZoneAPI, (zone, unit, item) =>
  60. {
  61. bool ret = Condition.GetValue(api, args);
  62. return ret;
  63. });
  64. }
  65. }
  66. }