public void ChangeState(IGameStates newGameState) { previousGameState = currentGameState; if (previousGameState != null) { previousGameState.OnStateExit(); } currentGameState = newGameState; currentGameState.OnStateEnter(); }