Beispiel #1
0
        public override void Update(GameTime gameTime)
        {
            input.Update();

            bool otherScreenHasFocus  = !Game.IsActive;
            bool coveredByOtherScreen = false;

            screensToUpdate.Clear();
            foreach (GameScreen screen in screens)
            {
                if (!screen.IsActive && !(screen is MainMenuScreen) && screen.bgSong != null)
                {
                    MediaPlayer.Stop();
                }
                screensToUpdate.Add(screen);
            }

            GameScreen s;

            //this is a weird way of doing this, but takes into account if a screen is needed to update twice
            while (screensToUpdate.Count > 0)
            {
                s = screensToUpdate[screensToUpdate.Count - 1];

                screensToUpdate.RemoveAt(screensToUpdate.Count - 1);
                s.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
                if (s.ScreenState == ScreenState.TransitionToOn || s.ScreenState == ScreenState.Active)
                {
                    if (!otherScreenHasFocus)
                    {
                        s.HandleInput(input);
                        otherScreenHasFocus = true;
                    }
                }
            }
        }