Esempio n. 1
0
        public void ChangeState(string toState)
        {
            FSMState stateToChange = null;

            foreach (FSMState state in _states)
            {
                if (state.name.Equals(toState))
                {
                    stateToChange = state;
                }
            }

            if (stateToChange != null)
            {
                _currentState.Exit();
                _currentState = stateToChange;
                _currentState.Enter();
            }
            else
            {
                Debug.LogError("Invalid State name: " + toState);
            }
        }