public override void Update(GameTime gameTime)
        {
            GameScreen screen = null;

            try
            {
                var flag1 = usingGamePad;
                usingGamePad = false;
                for (var index = 0; index < input.CurrentGamePadStates.Length; ++index)
                {
                    if (input.CurrentGamePadStates[index].IsConnected)
                    {
                        usingGamePad = true;
                    }
                }
                input.Update();
                screensToUpdate.Clear();
                foreach (var gameScreen in screens)
                {
                    screensToUpdate.Add(gameScreen);
                }
                if (screensToUpdate.Count == 0)
                {
                    foreach (var gameScreen in screens)
                    {
                        screensToUpdate.Add(gameScreen);
                    }
                }
                var otherScreenHasFocus  = !Game.IsActive;
                var coveredByOtherScreen = false;
                var flag2 = false;
                while (screensToUpdate.Count > 0)
                {
                    screen = screensToUpdate[screensToUpdate.Count - 1];
                    screensToUpdate.RemoveAt(screensToUpdate.Count - 1);
                    if (!otherScreenHasFocus &&
                        (screen.ScreenState == ScreenState.TransitionOn || screen.ScreenState == ScreenState.Active))
                    {
                        if (flag1 != usingGamePad)
                        {
                            screen.inputMethodChanged(usingGamePad);
                        }
                        screen.HandleInput(input);
                        flag2 = true;
                    }
                    screen.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
                    if (flag2)
                    {
                        otherScreenHasFocus = true;
                    }
                    if ((screen.ScreenState == ScreenState.TransitionOn || screen.ScreenState == ScreenState.Active) &&
                        !screen.IsPopup)
                    {
                        coveredByOtherScreen = true;
                    }
                }
                if (!TraceEnabled)
                {
                    return;
                }
                TraceScreens();
            }
            catch (Exception ex)
            {
                if (screen == null)
                {
                    return;
                }
                RemoveScreen(screen);
            }
        }
 public void AddScreen(GameScreen screen)
 {
     AddScreen(screen, controllingPlayer);
 }
예제 #3
0
 public void AddScreen(GameScreen screen, PlayerIndex? controllingPlayer)
 {
     screen.ControllingPlayer = controllingPlayer;
     screen.ScreenManager = this;
     screen.IsExiting = false;
     if (isInitialized)
         screen.LoadContent();
     screens.Add(screen);
 }
예제 #4
0
 public void RemoveScreen(GameScreen screen)
 {
     if (isInitialized)
         screen.UnloadContent();
     screens.Remove(screen);
     screensToUpdate.Remove(screen);
     if (screens.Count > 0)
         return;
     handleCriticalError();
 }
예제 #5
0
 public void AddScreen(GameScreen screen)
 {
     AddScreen(screen, controllingPlayer);
 }