/// <summary> /// 添加条件 /// </summary> /// <param name="parameterName">条件参数名</param> /// <param name="comType">比较类别</param> /// <param name="value">目标值</param> /// <returns></returns> public StateConditions With(string parameterName, ConditionOperationType comType, object value) { // 这里不去重复 // 比如 条件是一个区间 StateCondition condition = new StateCondition(); condition.Name = parameterName; condition.Value = value; condition.CompareType = comType; mConditions.Add(condition); return(this); }
public bool CheckCondition(StateCondition condition) { Assert(condition != null, "wrong condition"); StateControllerParameter param = mParameters[condition.Name]; Assert(param != null, "wrong parameter"); switch (param.DataType) { case StateParameterDataType.TRIGGER: return(true); case StateParameterDataType.BOOLEAN: return(param.Value.Equals(condition.Value)); case StateParameterDataType.FLOAT: case StateParameterDataType.INT: // int 也当作 浮点比较 // 当前值 param.Value 与 目标值 condition.Value 比较 return(CheckFloat((float)param.Value, (float)condition.Value, condition.CompareType)); } return(true); }