Beispiel #1
0
 // This uses the loading screen to transition from the game back to the main menu screen.
 private void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 {
     MediaPlayer.Stop();
     LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), new MainMenuScreen());
 }
Beispiel #2
0
 private void PlayGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, true, e.PlayerIndex, new GameplayScreen(), new SplashScreen());
 }
        // This method checks the GameScreen.IsActive property, so the game will
        // stop updating when the pause menu is active, or if you tab away to a different application.
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            batSprite.level = 2;
            // Gradually fade in or out depending on whether we are covered by the pause screen.
            if (coveredByOtherScreen)
            {
                _pauseAlpha = Math.Min(_pauseAlpha + 1f / 32, 1);
            }
            else
            {
                _pauseAlpha = Math.Max(_pauseAlpha - 1f / 32, 0);
            }

            if (IsActive)
            {
                // TODO: Add your update logic here
                batSprite.Update(gameTime);

                System.Random rand = new System.Random();
                foreach (var coin in coins)
                {
                    if (!coin.Collected && coin.Bounds.CollidesWith(batSprite.Bounds))
                    {
                        coinsCollected++;
                        coinPickup.Play();
                        coin.Move(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height));
                    }
                }

                exitSprite.position = new Vector2(800, 800);

                if (exit && batSprite.Bounds.CollidesWith(exitSprite.Bounds))
                {
                    LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), new MainMenuScreen());
                    MediaPlayer.Stop();
                }

                foreach (var coin in coins)
                {
                    coin.Update(gameTime);
                    if (!coin.Collected && coin.Bounds.Center.X <= 0)
                    {
                        coin.Velocity.X     = 100;
                        coin.Acceleration.X = 20;
                    }
                    if (!coin.Collected && coin.Bounds.Center.X >= ScreenManager.GraphicsDevice.Viewport.Width)
                    {
                        coin.Velocity.X     = -100;
                        coin.Acceleration.X = -20;
                    }

                    if (!coin.Collected && coin.Bounds.Center.Y <= 0)
                    {
                        coin.Velocity.Y     = 100;
                        coin.Acceleration.Y = 20;
                    }

                    if (!coin.Collected && coin.Bounds.Center.Y >= ScreenManager.GraphicsDevice.Viewport.Height)
                    {
                        coin.Velocity.Y     = -100;
                        coin.Acceleration.Y = -20;
                    }
                }
            }
            base.Update(gameTime, otherScreenHasFocus, false);
        }