//------------------------------------------------------------------------------ // Method: SetState // Author: Neil Holmes & Andrew Greeen // Summary: changes the current state - calls exit on the previous state and // enter on the new state. Will not allow the current state to be reset // returns true if the new state is set //----------------------------------------------------------------------------- public bool SetState(GameObjectState newState) { // check that we aren't trying to enter the state we are already in if (newState == currentState) return false; // if we have a current state, call it's exit method if (currentState != null) currentState.Exit(); // setup the new state newState.Enter(); // set the new state as the current state currentState = newState; // state set succesfully - return true return true; }
//------------------------------------------------------------------------------ // Method: Reset // Author: Neil Holmes & Andrew Greeen // Summary: resets the game object state manager - clears the current state //----------------------------------------------------------------------------- public void Reset() { // clear the current state currentState = null; }