Esempio n. 1
0
    public static StateFSM stateFsmFromEnumState(enumStates _state)
    {
        var query = AllStates.Where(a => a.fsmState == _state);

        if (query.Count() > 0)
        {
            return(query.First());
        }
        else
        {
            Debug.Log("FSMError - couldnt find state");
            return(null);
        }
    }
Esempio n. 2
0
 public static void InvokeEvent(enumEvents _event)
 {
     Debug.Log("FSMLog - invoking event " + _event.ToString());
     if (currentState.HasConsequence(_event))
     {
         if (currentState.exit != null)
         {
             currentState.exit();
         }
         enumStates nextState = currentState.NextState(_event);
         var        query     = AllStates.Where(a => a.fsmState == nextState);
         currentState = stateFsmFromEnumState(nextState);
         if (currentState.enter != null)
         {
             currentState.enter();
         }
         Debug.Log("FSMLog - Entering state " + currentState.fsmState.ToString());
     }
     else
     {
         Debug.Log("FSMERROR - state " + currentState.fsmState + " has no consequence for the event " + _event);
     }
     // StateFSM tempState ;
 }
Esempio n. 3
0
 public void AddConsequence(enumEvents _fsmEvent, enumStates _nextFsmState)
 {
     consequences.Add(_fsmEvent, _nextFsmState);
 }
Esempio n. 4
0
 public StateFSM(enumStates _fsmState, Dictionary <enumEvents, enumStates> _consequences)
 {
     consequences = _consequences;
     fsmState     = _fsmState;
 }
Esempio n. 5
0
 public StateFSM(enumStates _fsmState)
 {
     consequences = new Dictionary <enumEvents, enumStates>();
     fsmState     = _fsmState;
 }
Esempio n. 6
0
 //======================================================================//
 //    Call this function to change state									//
 //======================================================================//
 public void stateManager(int value)
 {
     States = (enumStates)value;
 }
Esempio n. 7
0
 public static void ForceState(enumStates _state)
 {
     currentState = stateFsmFromEnumState(_state);
 }
Esempio n. 8
0
 public static void AddEventConsequence(enumStates _fromState, enumEvents _event, enumStates _toState)
 {
     stateFsmFromEnumState(_fromState).AddConsequence(_event, _toState);
 }
Esempio n. 9
0
 public static void AddOnEnterCall(enumStates _state, Action _method)
 {
     stateFsmFromEnumState(_state).enter += _method;
 }
Esempio n. 10
0
 public static void AddOnExitCall(enumStates _state, Action _method)
 {
     stateFsmFromEnumState(_state).exit += _method;
 }
Esempio n. 11
0
 public static void AddOneState(enumStates _state)
 {
     AllStates.Add(new StateFSM(_state));
 }
Esempio n. 12
0
 public static bool InState(enumStates _state)
 {
     return(currentState == stateFsmFromEnumState(_state));
 }