Ejemplo n.º 1
0
 public Condition(State _endCondition, RelationalOperator _comparison)
 {
     endConditionState = _endCondition;
     comparison        = _comparison;
     isSatisfied       = false;
     holdingTimer      = null;
     holdingCount      = 0;
 }
Ejemplo n.º 2
0
 // constructor for dummy condition
 public Condition(bool _isSatisfied)
 {
     isSatisfied  = _isSatisfied;
     isActivated  = true;
     comparison   = RelationalOperator.NotEqual;
     holdingTimer = null;
     holdingCount = 0;
 }
Ejemplo n.º 3
0
 public Condition(State _endCondition, RelationalOperator _comparison, TimeState _elapsedState) : this(_endCondition, _comparison)
 {
     holdingTimer = _elapsedState;
 }
Ejemplo n.º 4
0
 public static RelationalOperator Inverse(RelationalOperator ope)
 {
     return(RelationalOperator.Code2Operator((ope.GetCode() + 3) % 6));
 }
Ejemplo n.º 5
0
 public static RelationalOperator Inverse(RelationalOperator ope)
 {
     return((RelationalOperator)(((int)ope + 3) % 6));
 }
Ejemplo n.º 6
0
        public bool Check(State state1, State state2, RelationalOperator ope, TimeState timeState = null)
        {
            if (isSatisfied)
            {
                return(true);
            }
            bool result = false;

            // unwrapping autovariable state: we convert it to the specific varible state inside of the AutoVariableState.
            if (state1.GetType() == typeof(AutoVariableState))
            {
                state1 = (state1 as AutoVariableState).GetVariableState();
            }
            if (state2.GetType() == typeof(AutoVariableState))
            {
                state2 = (state2 as AutoVariableState).GetVariableState();
            }

            if (state1.GetType() == state2.GetType())
            {
                //Debug.Log("Check: " + state1.ToString() + "\t" + state2.ToString());
                //Debug.Log(state1.CompareTo(state2));
                if (ope == RelationalOperator.Larger)
                {
                    result = state1.CompareTo(state2) > 0;
                }
                else if (ope == RelationalOperator.LargerOrEqual)
                {
                    result = state1.CompareTo(state2) > 0 || state1.Equals(state2);
                }
                else if (ope == RelationalOperator.Equal)
                {
                    result = state1.Equals(state2);
                }
                else if (ope == RelationalOperator.SmallerOrEqual)
                {
                    result = state1.CompareTo(state2) < 0 || state1.Equals(state2);
                }
                else if (ope == RelationalOperator.Smaller)
                {
                    result = state1.CompareTo(state2) < 0;
                }
                else if (ope == RelationalOperator.NotEqual)
                {
                    result = state1 != state2;
                }
            }
            if (holdingTimer != null)
            {
                if (result)
                {
                    if (holdingCount < 30)
                    {
                        holdingCount += 1;
                    }
                    if (!holdingTimer.IsTimerOn())
                    {
                        holdingTimer.StartTimer();
                    }
                }
                else
                {
                    if (holdingCount > 0)
                    {
                        holdingCount -= 1;
                    }
                    else
                    {
                        holdingTimer.StopTimer();
                    }
                }
                if (holdingTimer.IsOver())
                {
                    isSatisfied = true;
                }
            }
            else
            {
                isSatisfied = result;
            }
            return(isSatisfied);
        }