using CommonAI.RTS; using CommonLang.Vector; using CommonAI.Zone.Attributes; using CommonAI.Zone.Instance; using CommonAI.Zone.ZoneEditor; using CommonAI.Zone.ZoneEditor.EventTrigger; using CommonLang.Property; using System; using System.Collections.Generic; using System.Linq; using System.Text; using CommonAI.Zone.EventTrigger; namespace CommonAI.Zone.ZoneEditor.EventTrigger { //------------------------------------------------------------------------------------------- #region _设置_单位变量_ [DescAttribute("", "设置 - 单位变量")] public abstract class SetUnitVar : AbstractAction { [DescAttribute("变量名")] public string Key = "VarName"; [DescAttribute("单位")] public UnitValue Unit = new UnitValue.Trigging(); [DescAttribute("是否同步到客户端(如果需要客户端显示,则填True)")] public bool SyncToClient = true; public override string ToString() { return string.Format("单位({2})设置变量\"{0}\"={1}", Key, TValue, Unit); } override public void DoAction(EventTriggerAdapter api, EventArguments args) { InstanceUnit unit = Unit.GetValue(api, args); if (unit != null) { T value = TValue.GetValue(api, args); unit.SetEnvironmentVar(Key, value, SyncToClient); } } abstract public AbstractValue TValue { get; } } [DescAttribute("设置字符串型", "设置 - 单位变量")] public class SetUnitString : SetUnitVar { [DescAttribute("变量值")] public StringValue Value = new StringValue.VALUE("text"); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置整数型", "设置 - 单位变量")] public class SetUnitInteger : SetUnitVar { [DescAttribute("变量值")] public IntegerValue Value = new IntegerValue.VALUE(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置小数型", "设置 - 单位变量")] public class SetUnitReal : SetUnitVar { [DescAttribute("变量值")] public RealValue Value = new RealValue.VALUE(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置布尔型", "设置 - 单位变量")] public class SetUnitBool : SetUnitVar { [DescAttribute("变量值")] public BooleanValue Value = new BooleanValue.VALUE(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置单位", "设置 - 单位变量")] public class SetUnitUnit : SetUnitVar { [DescAttribute("变量值")] public UnitValue Value = new UnitValue.NA(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置Flag", "设置 - 单位变量")] public class SetUnitFlag : SetUnitVar { [DescAttribute("变量值")] public FlagValue Value = new FlagValue.NA(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置物品", "设置 - 单位变量")] public class SetUnitItem : SetUnitVar { [DescAttribute("变量值")] public ItemValue Value = new ItemValue.NA(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置位置坐标", "设置 - 单位变量")] public class SetUnitPosition : SetUnitVar { [DescAttribute("变量值")] public PositionValue Value = new PositionValue.VALUE(); override public AbstractValue TValue { get { return Value; } } } #endregion //------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------- #region _设置_单位变量_StringValueKey_ [DescAttribute("", "设置 - 单位变量(变量索引)")] public abstract class SetUnitVarStringValueKey : AbstractAction { [DescAttribute("变量名")] public StringValue Key = new StringValue.VALUE("VarName"); [DescAttribute("单位")] public UnitValue Unit = new UnitValue.Trigging(); [DescAttribute("是否同步到客户端(如果需要客户端显示,则填True)")] public bool SyncToClient = true; public override string ToString() { return string.Format("单位({2})设置变量\"{0}\"={1}", Key, TValue, Unit); } override public void DoAction(EventTriggerAdapter api, EventArguments args) { InstanceUnit unit = Unit.GetValue(api, args); string key = Key.GetValue(api, args); if (unit != null && key != null) { T value = TValue.GetValue(api, args); unit.SetEnvironmentVar(key, value, SyncToClient); } } abstract public AbstractValue TValue { get; } } [DescAttribute("设置字符串型", "设置 - 单位变量(变量索引)")] public class SetUnitStringStringValueKey : SetUnitVarStringValueKey { [DescAttribute("变量值")] public StringValue Value = new StringValue.VALUE("text"); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置整数型", "设置 - 单位变量(变量索引)")] public class SetUnitIntegerStringValueKey : SetUnitVarStringValueKey { [DescAttribute("变量值")] public IntegerValue Value = new IntegerValue.VALUE(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置小数型", "设置 - 单位变量(变量索引)")] public class SetUnitRealStringValueKey : SetUnitVarStringValueKey { [DescAttribute("变量值")] public RealValue Value = new RealValue.VALUE(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置布尔型", "设置 - 单位变量(变量索引)")] public class SetUnitBoolStringValueKey : SetUnitVarStringValueKey { [DescAttribute("变量值")] public BooleanValue Value = new BooleanValue.VALUE(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置单位", "设置 - 单位变量(变量索引)")] public class SetUnitUnitStringValueKey : SetUnitVarStringValueKey { [DescAttribute("变量值")] public UnitValue Value = new UnitValue.NA(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置Flag", "设置 - 单位变量(变量索引)")] public class SetUnitFlagStringValueKey : SetUnitVarStringValueKey { [DescAttribute("变量值")] public FlagValue Value = new FlagValue.NA(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置物品", "设置 - 单位变量(变量索引)")] public class SetUnitItemStringValueKey : SetUnitVarStringValueKey { [DescAttribute("变量值")] public ItemValue Value = new ItemValue.NA(); override public AbstractValue TValue { get { return Value; } } } [DescAttribute("设置位置坐标", "设置 - 单位变量(变量索引)")] public class SetUnitPositionStringValueKey : SetUnitVarStringValueKey { [DescAttribute("变量值")] public PositionValue Value = new PositionValue.VALUE(); override public AbstractValue TValue { get { return Value; } } } #endregion //------------------------------------------------------------------------------------------- }