123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- using CommonAI.Zone.Attributes;
- using CommonAI.Zone.Instance;
- using CommonLang.Property;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using CommonAI.Zone.EventTrigger;
- using CommonAI.Zone.Helper;
- namespace CommonAI.Zone.ZoneEditor.EventTrigger
- {
- [DescAttribute("触发的任务ID", "任务")]
- public class TriggingQuestIdentify : StringValue
- {
- public override string ToString()
- {
- return string.Format("触发的任务");
- }
- public override string GetValue(IEditorValueAdapter api, EventArguments args)
- {
- return args.TriggingQuestID;
- }
- }
- [DescAttribute("单位任务子状态查询", "任务")]
- public class GetQuestField : StringValue
- {
- [DescAttribute("单位")]
- public UnitValue Unit = new UnitValue.Trigging();
- [DescAttribute("任务ID")]
- public StringValue QuestID = new TriggingQuestIdentify();
- [DescAttribute("任务子状态字段")]
- public StringValue Key = new StringValue.VALUE("key");
- public override string ToString()
- {
- return string.Format("单位[{0}]任务[{1}]子状态[{2}]", Unit, QuestID, Key);
- }
- public override string GetValue(IEditorValueAdapter api, EventArguments args)
- {
- InstancePlayer p = Unit.GetValue(api, args) as InstancePlayer;
- if (p != null)
- {
- string quest_id = QuestID.GetValue(api, args);
- string key = Key.GetValue(api, args);
- if (!string.IsNullOrEmpty(quest_id) && !string.IsNullOrEmpty(key))
- {
- QuestData qd = p.GetQuest(quest_id);
- if (qd != null)
- {
- return qd.Attributes.Get(key);
- }
- }
- }
- return null;
- }
- }
- [DescAttribute("单位任务主状态判断", "任务")]
- public class GetQuestState : BooleanValue
- {
- [DescAttribute("单位")]
- public UnitValue Unit = new UnitValue.Trigging();
- [DescAttribute("任务ID")]
- public StringValue QuestID = new TriggingQuestIdentify();
- [DescAttribute("预期任务状态")]
- public QuestState ExpectState = QuestState.Accepted;
- public override string ToString()
- {
- return string.Format("单位[{0}]任务[{1}]状态是否为{2}", Unit, QuestID, ExpectState);
- }
- public override Boolean GetValue(IEditorValueAdapter api, EventArguments args)
- {
- InstancePlayer p = Unit.GetValue(api, args) as InstancePlayer;
- if (p != null)
- {
- string quest_id = QuestID.GetValue(api, args);
- if (!string.IsNullOrEmpty(quest_id))
- {
- QuestData qd = p.GetQuest(quest_id);
- if (qd != null)
- {
- return qd.State == ExpectState;
- }
- }
- }
- return false;
- }
- }
- [DescAttribute("任务是否已接受", "任务")]
- public class QuestAccepted : BooleanValue
- {
- [DescAttribute("单位 - 某个单位")]
- public UnitValue Unit = new UnitValue.Trigging();
- [QuestIDAttribute]
- [DescAttribute("任务ID")]
- public string Quest;
- public override string ToString()
- {
- return string.Format("任务[{0}]是否已接受", Quest);
- }
- public override bool GetValue(IEditorValueAdapter api, EventArguments args)
- {
- InstancePlayer p = Unit.GetValue(api, args) as InstancePlayer;
- if (p != null)
- {
- return p.IsQuestAccepted(Quest);
- }
- return false;
- }
- }
- [DescAttribute("任务是否已接受(变量)", "任务")]
- public class QuestAcceptedSV : BooleanValue
- {
- [DescAttribute("单位 - 某个单位")]
- public UnitValue Unit = new UnitValue.Trigging();
- [DescAttribute("任务ID")]
- public StringValue QuestID = new TriggingQuestIdentify();
- public override string ToString()
- {
- return string.Format("任务[{0}]是否已接受", QuestID);
- }
- public override bool GetValue(IEditorValueAdapter api, EventArguments args)
- {
- InstancePlayer p = Unit.GetValue(api, args) as InstancePlayer;
- string questID = QuestID.GetValue(api, args);
- if (p != null)
- {
- return p.IsQuestAccepted(questID);
- }
- return false;
- }
- }
- }
|