예제 #1
0
        public IEnumerator Update()
        {
            while (Active)
            {
                CurrentState.UpdateLoop();

                var nextState        = CurrentState.ProcessInput();
                var stateTransitions = 0;

                Callback_state.Invoke(CurrentState.Name + " > " + nextState.Name);

                //Debug.Log("El next state se espera que sea: " + nextState.Name);

                while (nextState != CurrentState && stateTransitions < _MAX_TRANSITIONS_PER_FRAME)
                {
                    var previousState        = CurrentState;
                    var transitionParameters = CurrentState.Exit(nextState);

                    Debug.Log("Exiting state '" + CurrentState.Name + "'");
                    Debug.Log(" to  state '" + nextState.Name + "'.");

                    txt_Debug.text = "from: " + CurrentState.Name + " To: " + nextState.Name + ".";

                    CurrentState = nextState;
                    CurrentState.Enter(previousState, transitionParameters);

                    nextState = CurrentState.ProcessInput();

                    stateTransitions++;
                }

                yield return(null);
            }
        }
예제 #2
0
        public IEnumerator Update()
        {
            while (Active)
            {
                CurrentState.UpdateLoop();

                var nextState        = CurrentState.ProcessInput();
                var stateTransitions = 0;

                while (nextState != CurrentState && stateTransitions < _MAX_TRANSITIONS_PER_FRAME)
                {
                    var previousState        = CurrentState;
                    var transitionParameters = CurrentState.Exit(nextState);

                    Debug.Log("Exiting state '" + CurrentState.Name + "' to state '" + nextState.Name + "'.");

                    CurrentState = nextState;
                    CurrentState.Enter(previousState, transitionParameters);

                    nextState = CurrentState.ProcessInput();

                    stateTransitions++;
                }

                yield return(null);
            }
        }
예제 #3
0
 public void ChangeState(IState nextState)
 {
     currentState?.Exit();
     currentState = nextState;
     currentState.Enter();
 }