public static TimeSpan GetGlobalTimer() { if (globalTimer == null) { globalTimer = new TimeState(); globalTimer.StartTimer(); } return(globalTimer.value.GetValue()); }
protected override bool Check(State state1, Operator ope, State state2, 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); }