Exemplo n.º 1
0
        public void die()
        {
            livesRemaining--;
            if (!hasMoreLives())
            {
                if (backpackmenu.isShowing())
                {
                    backpackmenu.Hide();
                }
                if (timex.isShowing())
                {
                    timex.Hide();
                }
                gameEnded = true;
                return;
            }

            LoadLevel(game_state.tile_engine.getCurrentLevel());
        }
Exemplo n.º 2
0
        public void die() // user has died in a level. level will start over and a life will be decucted
        {
            livesRemaining--;
            if (!hasMoreLives()) // if the user has 0 more lives, game over
            {
                if (backpackmenu.isShowing())
                {
                    backpackmenu.Hide();
                }
                if (timex.isShowing())
                {
                    timex.Hide();
                }
                gameEnded = true;
                return;
            }

            LoadLevel(game_state.tile_engine.getCurrentLevel()); // restart if the user has more lives
        }
Exemplo n.º 3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            if (DEV_MODE)
            {
                if (intro.isShowing())
                {
                    intro.Hide();
                }
                if (instruct.isShowing())
                {
                    instruct.Hide();
                }
                if (instruct2.isShowing())
                {
                    instruct2.Hide();
                }
            }

            if (intro.isShowing()) // if the introduction screen is showing, continue showing until introTime runs out (5 seconds)
            {
                intro.update(gameTime);
            }
            else if (instruct.isShowing()) // if instructions are showing, continue showing for 5 seconds and let it advance
            {
                instruct.update(gameTime);
            }
            else if (instruct2.isShowing()) // if second instructions are showing, continue showing
            {
                instruct2.update(gameTime);
            }
            else if (timex.isShowing()) // user ran out of time, time expired screen is up. will wait here for user to choose to play again or not
            {
                timex.update(gameTime);
                if (timex.play_again)             // user wants to play again
                {
                    timex.Hide();                 // so hide game screen and
                    timex.reset();
                    game_engine.Update(gameTime); // go to game environment
                }
                else if (!timex.isRunning())      // user did not select play again before time ran out
                {
                    timex.Hide();
                    spriteBatch.Begin();
                    gameover.Show(spriteBatch); // exit game
                    spriteBatch.End();
                }
            }
            else if (gameover.isShowing()) // game over screen is showing
            {
                gameover.update(gameTime);
                if (gameover.exit)
                {
                    this.Exit(); // end game
                }
            }
            else
            {
                game_engine.Update(gameTime);
                if (game_engine.gameEnded)
                {
                    spriteBatch.Begin();
                    gameover.Show(spriteBatch);
                    spriteBatch.End();
                }
            }


            base.Update(gameTime);
        }