Exemplo n.º 1
0
 /// <summary>
 /// 该控制参数名不能重复
 /// </summary>
 /// <param name="paraName">参数名</param>
 /// <param name="dataType">参数类型</param>
 /// <param name="ctlValue">参数控制值</param>
 /// <returns></returns>
 public StateController <T> AddParameter(string paraName, StateParameterDataType dataType, object ctlValue)
 {
     if (!mParameters.ContainsKey(paraName))
     {
         StateControllerParameter param = new StateControllerParameter();
         param.Name     = paraName;
         param.DataType = dataType;
         param.Value    = ctlValue;
         mParameters.Add(paraName, param);
     }
     else
     {
         // duplicated
     }
     return(this);
 }
Exemplo n.º 2
0
        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);
        }