void Start() { if (initialState != null) { currentState = initialState; initialState.EnterState(); } }
//=========================================================// // Declare public methods public void EnterState(StateType stateType) { // First, check the state type is in the dictionary if (fsmStates.ContainsKey(stateType)) { // Get the state from the dictionary AbstractCatFSMState state = fsmStates[stateType]; // Exit the current state if (currentState != null) { currentState.ExitState(); } // Set the current state to this state and enter state currentState = state; currentState.EnterState(); } }