Exemple #1
0
        private void PlayGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            GameplayScreen currentGameScreen = null;

            foreach (var gs in ScreenManager.GetScreens())
            {
                if (gs is GameplayScreen g)
                {
                    currentGameScreen = g;
                    break;
                }
            }
            if (currentGameScreen == null)
            {
                LoadingScreen.Load(ScreenManager, true, e.PlayerIndex, new GameplayScreen(difficultyProxy));
            }
            else
            {
                LoadingScreen.Load(ScreenManager, true, e.PlayerIndex, currentGameScreen);
            }
        }
        // This uses the loading screen to transition from the game back to the main menu screen.
        private void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
        {
            // persist state across quits
            GameplayScreen currentGameScreen = null;

            foreach (var gs in ScreenManager.GetScreens())
            {
                if (gs is GameplayScreen g)
                {
                    currentGameScreen = g;
                    break;
                }
            }
            if (currentGameScreen == null)
            {
                LoadingScreen.Load(ScreenManager, true, null, new BackgroundScreen(), new MainMenuScreen());
            }
            else
            {
                LoadingScreen.Load(ScreenManager, true, null, currentGameScreen, new BackgroundScreen(), new MainMenuScreen());
            }
        }
 private void RestartGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), new GameplayScreen());
 }
 // This uses the loading screen to transition from the game back to the main menu screen.
 private void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), new MainMenuScreen());
 }
Exemple #5
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);
        }