Esempio n. 1
0
        public MenuState.GameState GameState(MenuState.GameState CurrentGameState)
        {
            if (CurrentGameState == MenuState.GameState.Playing)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                {
                    CurrentGameState = MenuState.GameState.Pause;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad1) && Keyboard.GetState().IsKeyDown(Keys.NumPad4) && Keyboard.GetState().IsKeyDown(Keys.NumPad8))
                {
                    Score = 0;
                }

                if (PlayerTakeDamage)
                {
                    CurrentGameState = MenuState.GameState.GameOver;
                    PlayerTakeDamage = false;
                }
                if (CanCompleteLevel)
                {
                    CurrentGameState = MenuState.GameState.LevelComplete;
                    CanCompleteLevel = false;
                    MediaPlayer.Pause();
                    Levelcomplete.Play();
                }
                MediaPlayer.IsRepeating = true;
            }
            return(CurrentGameState);
        }
Esempio n. 2
0
 public Main()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     ScreenWidth           = graphics.PreferredBackBufferWidth = 1280; // Width
     ScreenHeight          = graphics.PreferredBackBufferHeight = 720; // Height
     graphics.IsFullScreen = false;                                    //SceenMode
     CurrentGameState      = MenuState.GameState.MainMenu;
 }
Esempio 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)
        {
            #region MenuUpdate
            switch (CurrentGameState)
            {
            case MenuState.GameState.NewGame:
                Level = options.Level;
                StartGame(Level, options.HealthPoint);
                options.HealthPoint = HealthPoint;
                MediaPlayer.Stop();
                CurrentGameState = MenuState.GameState.Playing;
                MediaPlayer.Play(GameTheme);
                if (CurrentGameState == MenuState.GameState.Playing)
                {
                    logic.Update(map, player, camera, gameTime);
                }
                break;

            case MenuState.GameState.Playing:
                CurrentGameState = logic.GameState(CurrentGameState);
                logic.Update(map, player, camera, gameTime);
                pauseSound = true;
                break;

            case MenuState.GameState.Options:
                CurrentGameState = options.Update();
                Level            = options.Level;
                HealthPoint      = options.HealthPoint;
                break;

            case MenuState.GameState.LevelComplete:
                CurrentGameState = levelComplete.Update(logic.Score);
                options.Level    = logic.Level;
                break;

            case MenuState.GameState.MainMenu:
                options.Level    = Level;
                pauseSound       = true;
                CurrentGameState = mainmenu.Update();
                break;

            case MenuState.GameState.GameOver:
                CurrentGameState = gameOver.Update(player.Health, player.HasDamaged);
                break;

            case MenuState.GameState.Pause:
                MediaPlayer.Pause();
                CurrentGameState = pause.Update();
                if (pauseSound)
                {
                    pause.PlaySound();
                    pauseSound = false;
                }
                break;

            case MenuState.GameState.Exit:
                Exit();
                break;

            default:
                break;
            }

            if (CurrentGameState == MenuState.GameState.GameOver && !gameOver.Over)
            {
                animationSprite.PlayAnimation(death);
            }
            else
            {
                animationSprite.PlayAnimation(null);
            }
            #endregion
            base.Update(gameTime);
        }