Example #1
0
 /// <summary>
 /// Event handler for when the user selects ok on the "are you sure
 /// you want to quit" message box. This uses the loading screen to
 /// transition from the game back to the main menu screen.
 /// </summary>
 void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(),
                        new MainMenuScreen());
 }
Example #2
0
        /// <summary>
        /// Updates the state of the game. 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.
        /// </summary>
        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)
            {
                MC.Update(gameTime);

                if (MC.isDead)
                {
                    LoadingScreen.Load(ScreenManager, true, 0,
                                       new Level1());
                }



                cam2D.Update(gameTime);

                //Robots
                {
                    foreach (Robot robot in Enemies)
                    {
                        robot.Update(gameTime);
                        if (robot.isDead)
                        {
                            world.RemoveBody(robot.robotBody);
                        }
                    }

                    for (int i = 0; i < Enemies.Count; i++)
                    {
                        if (Enemies[i].isDead)
                        {
                            MC.score += 2;
                            Enemies.RemoveAt(i);
                        }
                    }
                }
                //Stars
                {
                    foreach (Star star in Stars)
                    {
                        if (star.wasCollected)
                        {
                            world.RemoveBody(star.starBody);
                        }
                    }

                    for (int i = 0; i < Stars.Count; i++)
                    {
                        if (Stars[i].wasCollected)
                        {
                            Stars.RemoveAt(i);
                            MC.score++;
                        }
                    }
                }

                //Level 1 Script
                {
                    if (MC.score >= 5)
                    {
                        LoadingScreen.Load(ScreenManager, true, 0, new Level2());
                    }
                }

                cam2D.MaxRotation = 0.001f;
                cam2D.MinRotation = -0.001f;

                cam2D.MaxPosition = new Vector2(((MC.playerBody.Position.X) * 64 + 1), ((MC.playerBody.Position.Y) * 64) + 1);
                cam2D.MinPosition = new Vector2(((MC.playerBody.Position.X) * 64) + 2, ((MC.playerBody.Position.Y) * 64) + 1);
                cam2D.Update(gameTime);

                world.Step((float)gameTime.ElapsedGameTime.TotalMilliseconds * 0.001f);
            }
        }
Example #3
0
 /// <summary>
 /// Event handler for when the Play Game menu entry is selected.
 /// </summary>
 void PlayGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                        new Level1());
 }