public void SwitchTo(string name) { if (gameStates.ContainsKey(name)) { previousGameState = currentGameState; currentGameState = gameStates[name]; currentGameState.Setup(); } else { throw new KeyNotFoundException("Could not find game state: " + name); } }