public SM(Character a_controller, State sInitialState) { controller = a_controller; //uses this function to initalise the first state rather than assigning it //so the state machine is passed to the state itself ChangeState(sInitialState); }
public void ChangeState(State sNewState) { if (currentState != null) { previousState = currentState; currentState.ExitState (); } currentState = sNewState; currentState.EnterState(this); }