Пример #1
0
        /// <summary>
        /// Change the current state to a new state
        /// </summary>
        /// <param name="newState">The new state to change to </param>
        public void ChangeState(State newState)
        {
            if (currentState == newState)
            {
                return;
            }

            //check null for initialization
            if (currentState != null)
            {
                //Exit the current state
                currentState.Exit();
                _LogState("Exit");
            }

            //Make current state as previous
            prevState = currentState;

            //Make the new state as current
            currentState = newState;

            //Enter the new state
            currentState.Entry();

            _LogState("Entry");
        }
Пример #2
0
        public void ChangeState(State <T> newState)
        {
            if (currentState != null)
            {
                currentState.Exit();
            }

            currentState = newState;
            currentState.Init(this, refScript);
            DebugMessage("Entering");
            currentState.Enter();
            DebugMessage(newState.GetType().Name);
        }
Пример #3
0
        public void ChangeState(TStateType newState)
        {
            if (currentState != null)
            {
                currentState.Exit();
            }

            currentState = stateDictionary[newState];

            if (currentState != null)
            {
                currentState.Enter();
            }
        }
Пример #4
0
 public void ChangeState(State <T> newState)
 {
     if (newState == null)
     {
         Debug.Log("Trying to change to a null State");
     }
     else
     {
         previousState = currentState;
         currentState.Exit(owner);
         currentState = newState;
         currentState.Enter(owner);
     }
 }
Пример #5
0
        public void ChangeState(State newState)
        {
            if (currentState != null)
            {
                currentState.Exit();
            }

            currentState = newState;

            if (currentState != null)
            {
                currentState.SetCharacter(character);

                currentState.Enter();
            }
        }