예제 #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)
 {
     LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), new MainMenuScreen());
 }
예제 #2
0
        // 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)
        {
            base.Update(gameTime, otherScreenHasFocus, false);
            // 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)
            {
                slime.Update(gameTime);

                foreach (var food in foods)
                {
                    if (!food.Eaten && food.Bounds.CollidesWith(slime.Bounds) && !slime.Full)
                    {
                        slime.shrinkTimer = 0;
                        eatSound.Play();
                        slime.Size += .75f;
                        slime.AdjustRadius();
                        food.Eaten = true;
                        slime.foodEaten++;
                    }
                }
                if (slime.foodEaten > 5)
                {
                    slime.Full = true;
                }
                if (slime.Full)
                {
                    gameTimer = 0;
                    MediaPlayer.Stop();
                    LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), new MainMenuScreen());
                }
                foreach (var food in foods)
                {
                    food.Update(gameTime);
                    if (food.bounds.Center.X >= ScreenManager.GraphicsDevice.Viewport.Width)
                    {
                        food.Velocity.X     = -100;
                        food.Acceleration.X = -20;
                    }
                    if (food.bounds.Center.X <= 0)
                    {
                        food.Velocity.X     = 100;
                        food.Acceleration.X = 20;
                    }
                    if (food.bounds.Center.Y >= ScreenManager.GraphicsDevice.Viewport.Height)
                    {
                        food.Velocity.Y     = -100;
                        food.Acceleration.Y = -20;
                    }
                    if (food.bounds.Center.Y <= 0)
                    {
                        food.Velocity.Y     = 100;
                        food.Acceleration.Y = 20;
                    }
                }
            }
        }
예제 #3
0
 private void RestartGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, true, e.PlayerIndex, new GameplayScreen());
 }