Beispiel #1
0
        /// <summary>
        /// Changes the current state with a registered state
        /// </summary>
        /// <param name="state">Name of the state</param>
        public bool SetCurrentState(string state)
        {
            //Run exiting code for the current state
            if (currentState != null)
            {
                currentState.OnExit();
            }

            //Set the new current state
            currentState = statesList.FindFirst(state);

            //Run the entering code for the new current state
            if (currentState != null)
            {
                return(currentState.OnEnter());
            }

            return(false);
        }