protected override void SetConditionType(ConditionCompareType compareType) { switch (compareType) { case ConditionCompareType.SmallerThanCompare: case ConditionCompareType.BiggerThanCompare: throw new Exception("The Type is Illeagal whith " + type); case ConditionCompareType.EqualsWithCompare: case ConditionCompareType.NotEqualsWithCompare: this.compareType = compareType; break; } }
public StringTransitionCondition(FsmConditionValue <string> cconditionValue, object CompareValue, ConditionCompareType compareType) : base(cconditionValue, CompareValue, compareType) { }
/// <summary> /// 设置比较值 /// </summary> /// <param name="compareType"></param> protected abstract void SetConditionType(ConditionCompareType compareType);
/// <summary> /// Ctor /// </summary> /// <param name="cconditionValue">改变的数值</param> /// <param name="compareValue">比较的默认值</param> /// <param name="compareType">比较方式</param> protected TransitionCondition(FsmConditionValue <T> cconditionValue, object compareValue, ConditionCompareType compareType) { this._conditionValue = cconditionValue; this._compareValue = (T)compareValue; SetConditionType(compareType); }
public BoolTransitionCondition(FsmConditionValue <bool> conditionValue, object compareValue, ConditionCompareType compareType) : base(conditionValue, compareValue, compareType) { }
protected override void SetConditionType(ConditionCompareType compareType) { this.compareType = compareType; }
public FloatTransitionCondition(FsmConditionValue <float> conditionValue, object compareValue, ConditionCompareType compareType) : base(conditionValue, compareValue, compareType) { }
/// <summary> /// 创建过度条件 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="value"></param> /// <param name="CompareValue"></param> /// <param name="CompareType"></param> /// <returns></returns> public TransitionCondition<T> CreateCondition<T>(FsmConditionValue<T> value, T CompareValue, ConditionCompareType CompareType) { ITransitionCondition condtion; if (typeof(T) == typeof(bool)) condtion = new BoolTransitionCondition(value as FsmConditionValue<bool>, CompareValue, CompareType); else if (typeof(T) == typeof(string)) condtion = new StringTransitionCondition(value as FsmConditionValue<string>, CompareValue, CompareType); else if (typeof(T) == typeof(float)) condtion = new FloatTransitionCondition(value as FsmConditionValue<float>, CompareValue, CompareType); else if (typeof(T) == typeof(int)) condtion = new IntTransitionCondition(value as FsmConditionValue<int>, CompareValue, CompareType); else throw new Exception("Fault Type Of T " + typeof(T)); return condtion as TransitionCondition<T>; }
/// <summary> /// 创建过度条件 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="conditionValName"></param> /// <param name="CompareValue"></param> /// <param name="CompareType"></param> /// <returns></returns> public TransitionCondition<T> CreateCondition<T>(string conditionValName, T CompareValue, ConditionCompareType CompareType) { if (!_conditionValues.ContainsKey(typeof(T)) || !_conditionValues[typeof(T)].ContainsKey(conditionValName)) { Log.E("Please Create ConditionVal First Type " + typeof(T) + " Name " + conditionValName); return default(TransitionCondition<T>); } return CreateCondition(_conditionValues[typeof(T)][conditionValName] as FsmConditionValue<T>, CompareValue, CompareType); }