Пример #1
0
 public ScreenManager()
 {
     mScreens = new List<Screen>();
     GameScreen gameScreen = new GameScreen();
     MenuScreen menuScreen = new MenuScreen();
     mCurrentScreen = gameScreen;
     AddScreen(menuScreen);
     AddScreen(gameScreen);
     mScreenState = ScreenState.Playing;
 }
Пример #2
0
 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();
 }
Пример #3
0
 public void RemoveScreen(Screen screen)
 {
     mScreens.Remove(screen);
 }
Пример #4
0
 public void AddScreen(Screen screen)
 {
     mScreens.Add(screen);
 }