// Update is called once per frame
    void Update()
    {
        if (CurrentState == null)
        {
            CurrentState = last;
        }
        else
        {
            if (CurrentState != null && CurrentState.ExecutionState == ExecutionState.NONE)
            {
                CurrentState.EnterState();
            }
            else
            {
                next = CurrentState.UpdateState();
                if (next != CurrentState)
                {
                    last = CurrentState;
                    last.ExitState();
                    CurrentState = next;
                    CurrentState.EnterState();

                    Debug.Log("Switching state from " + last.Name + " to " + CurrentState.Name);
                    gameInfo.UpdateAbstractState(CurrentState);
                }
            }
        }
    }
Ejemplo n.º 2
0
 public void EnterState(AbstractState nextState)
 {
     if (nextState == null)
     {
         return;
     }
     else
     {
         if (_currentState != null)
         {
             _currentState.ExitState();
         }
         _currentState = nextState;
         _currentState.EnterState();
     }
 }
Ejemplo n.º 3
0
 public void TransitionToState(AbstractState state)
 {
     currentState = state;
     currentState.EnterState(this);
 }
Ejemplo n.º 4
0
 public PlayerMovementFSM()
 {
     currentState = idle;
     currentState.EnterState(this);
 }