예제 #1
0
        private void InitializeState(State state)
        {
            Type type = state.GetType();

            state.Initialize(this);
            _stateDict.Add(type, state);
        }
예제 #2
0
        /// <summary>
        /// Set current state and call states on enter and exit method
        /// </summary>
        /// <param name="state">State to enter</param>
        public void SetState(State state)
        {
            if (CurrentState != null)
            {
                CurrentState.OnStateExit();
            }

            PreviousState   = CurrentState;
            CurrentState    = state;
            gameObject.name = "State - " + state.GetType().Name;

            if (CurrentState != null)
            {
                CurrentState.OnStateEnter();
            }
        }