// 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);
                }
            }
        }
    }
示例#2
0
 public void EnterState(AbstractState nextState)
 {
     if (nextState == null)
     {
         return;
     }
     else
     {
         if (_currentState != null)
         {
             _currentState.ExitState();
         }
         _currentState = nextState;
         _currentState.EnterState();
     }
 }