private void ChangeScreen(ScreenState screenState) { switch (screenState) { case ScreenState.Title: { ChangeScreen(screenState, new CreateScreen(CreateTitleScreen)); break; } case ScreenState.Options: { ChangeScreen(screenState, new CreateScreen(CreateOptionScreen)); break; } case ScreenState.Gameplay: { ChangeScreen(screenState, new CreateScreen(CreateGameplayScreen)); break; } case ScreenState.GameOver: { ChangeScreen(screenState, new CreateScreen(CreateGameOverScreen)); break; } case ScreenState.GameWin: { ChangeScreen(screenState, new CreateScreen(CreateGameWinScreen)); break; } case ScreenState.PreviousScreen: { currentScreen = previousScreen; currentScreen.Activate(); break; } case ScreenState.Exit: { game.Exit(); break; } } }
private void ChangeScreen(ScreenState screenState, CreateScreen createScreen) { previousScreen = currentScreen; if (!screens.ContainsKey(screenState)) { screens.Add(screenState, createScreen()); screens[screenState].LoadContent(); } currentScreen = screens[screenState]; currentScreen.Activate(); }