public ScreenManager() { mScreens = new List<Screen>(); GameScreen gameScreen = new GameScreen(); MenuScreen menuScreen = new MenuScreen(); mCurrentScreen = gameScreen; AddScreen(menuScreen); AddScreen(gameScreen); mScreenState = ScreenState.Playing; }
private void ListenForScreenEvents() { if(Keyboard.GetState().IsKeyDown(Keys.Escape) && mPreviousKeyboardState.IsKeyUp(Keys.Escape)) { if(mScreenState == ScreenState.Playing) { mScreenState = ScreenState.Paused; mCurrentScreen = mScreens.Where(s => s.GetType() == typeof(MenuScreen)).Select(s => s as MenuScreen).FirstOrDefault(); } else if(mScreenState == ScreenState.Paused) { mScreenState = ScreenState.Playing; mCurrentScreen = mScreens.Where(s => s.GetType() == typeof(GameScreen)).Select(s => s as GameScreen).FirstOrDefault(); } } mPreviousKeyboardState = Keyboard.GetState(); }
public void RemoveScreen(Screen screen) { mScreens.Remove(screen); }
public void AddScreen(Screen screen) { mScreens.Add(screen); }