Exemple #1
0
        public static void Update(GameTime gT)
        {
            switch (GameState)
            {
            case GameState.MainMenu:
                MenuManager.Update();
                break;

            case GameState.HowToPlay:
                // Await input to go back to main menu
                if (InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.A) ||
                    (InputHelper.WasKeyPressed(Keys.Space)) ||
                    (InputHelper.WasKeyPressed(Keys.Enter)))
                {
                    SoundManager.PlaySound("PickUpItem");
                    GameState = GameState.MainMenu;
                }
                break;

            case GameState.Playing:
                // Update the Level
                if (InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.Back) ||
                    (InputHelper.WasKeyPressed(Keys.Escape)) ||
                    InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.Start))
                {
                    SoundManager.PlaySound("PickUpItem");
                    GameState = GameState.MainMenu;
                }

                Levels[CurrentLevel].Update(gT);
                break;
            }
        }
Exemple #2
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)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Escape) || exitGame)
            {
                Exit();
            }

            if (isLoading)
            {
                base.Update(gameTime);
            }
            ;

            // Switch to the next bloom settings preset?
            if (InputHelper.WasKeyPressed(Keys.B))
            {
                bloomSettingsIndex = (bloomSettingsIndex + 1) % BloomSettings.PresetSettings.Length;
                bloom.Settings     = BloomSettings.PresetSettings[bloomSettingsIndex];
            }

            if (GamePad.GetState(PlayerIndex.One).Triggers.Right > 0.00001f)
            {
                _zoom = 1.5f;
            }

            if (GamePad.GetState(PlayerIndex.One).Triggers.Left > 0.00001f)
            {
                _zoom = 1f;
            }

            cam.UpdateCameraZoom(_zoom, gameTime);
            // bloom.UpdateBloom(bloomIntensityIndex, gameTime);

            InputHelper.UpdateStates();
            GameManager.Update(gameTime);
            MusicManager.Update();

            // Just for fun - here I've added a pulse animation by adjusting the bloom saturation:

            /*BloomSatPulse += bloomSatDir;
             * if (BloomSatPulse > 2.5f) bloomSatDir = -0.09f;
             * if (BloomSatPulse < 0.1f) bloomSatDir = 0.09f;
             * bloom.Settings.BloomSaturation = BloomSatPulse;*/

            base.Update(gameTime);
        }
        public void PlayScene(GameTime gT)
        {
            currentTime -= (float)gT.ElapsedGameTime.TotalSeconds;

            // This line has been showing itself for long enough
            if (currentTime <= 0)
            {
                GoToNextLine();
            }

            if (InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.A) ||
                InputHelper.WasKeyPressed(Keys.Space))
            {
                //SoundManager.StopVoiceSound();
                GoToNextLine();
            }
        }
        public static void Update()
        {
            switch (MenuState)
            {
            case MenuState.TitleScreen:

                if (InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.A) ||
                    InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.Start) ||
                    InputHelper.WasKeyPressed(Keys.Space) ||
                    InputHelper.WasKeyPressed(Keys.Enter))
                {
                    MenuState = MenuState.MainMenu;
                }
                break;

            case MenuState.MainMenu:
                // Menu Navigation
                if (InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.DPadUp) ||
                    (InputHelper.NGS[(int)PlayerIndex.One].ThumbSticks.Left.Y <0.3 &&
                                                                               InputHelper.NGS[(int)PlayerIndex.One].ThumbSticks.Left.Y> 0.3) ||
                    InputHelper.WasKeyPressed(Keys.Up))
                {
                    currentMenuItem--;
                    if (currentMenuItem < 0)
                    {
                        currentMenuItem = menuItems.Count - 1;
                    }
                    SoundManager.PlaySound("PickUpItem");
                }

                if (InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.DPadDown) ||
                    (InputHelper.NGS[(int)PlayerIndex.One].ThumbSticks.Left.Y <-0.3 &&
                                                                               InputHelper.NGS[(int)PlayerIndex.One].ThumbSticks.Left.Y> -0.3) ||
                    InputHelper.WasKeyPressed(Keys.Down))
                {
                    currentMenuItem++;
                    if (currentMenuItem >= menuItems.Count)
                    {
                        currentMenuItem = 0;
                    }
                    SoundManager.PlaySound("PickUpItem");
                }


                //Menu Item Actions
                if (InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.A) ||
                    (InputHelper.WasKeyPressed(Keys.Space)) ||
                    (InputHelper.WasKeyPressed(Keys.Enter)))
                {
                    SoundManager.PlaySound("PickUpItem");

                    switch (currentMenuItem)
                    {
                    case 0:         // Begin Game

                        GameManager.GameState = GameState.Playing;
                        GameManager.CreateLevels();
                        MusicManager.StopSong();
                        MusicManager.PlaySong("music01");
                        MusicManager.SetRepeating(true);

                        break;

                    case 1:         // How To Play
                        GameManager.GameState = GameState.HowToPlay;
                        break;

                    case 2:         // Exit Game
                        Game1.ExitGame();
                        break;
                    }
                }

                break;
            }
        }
        public void Update(GameTime gT)
        {
            switch (this.LevelState)
            {
                #region Intro

            case LevelState.Intro:
                Player1.Update(gT);

                break;
                #endregion

                #region Cutscene

            case LevelState.CutScene:
                CutScenes[CurrentCutScene].PlayScene(gT);
                break;

                #endregion

                #region Playing
            case LevelState.Playing:
                // Update the Actors
                for (int i = 0; i < Actors.Count; i++)
                {
                    Actors[i].Update(gT);
                }

                // Update Game Items
                for (int i = 0; i < GameItems.Count; i++)
                {
                    GameItems[i].Update(gT);
                }

                // Update Enemy Spawners
                for (int i = 0; i < EnemySpawners.Count; i++)
                {
                    EnemySpawners[i].Update(gT);
                }

                // Update Camera Position
                UpdateCameraPosition(gT);

                // Update Trigger
                this.CurrentTrigger.Update();

                // Extend the play area?
                if (InputHelper.WasKeyPressed(Keys.Q))
                {
                    AddToPlayBounds(150);
                }

                break;
                #endregion

                #region Continue

            case LevelState.Continue:
                TimerContinue -= (float)gT.ElapsedGameTime.TotalSeconds;
                // TimerContinue Finished
                if (TimerContinue <= 0)
                {
                    // Out of time, Game Over
                    this.LevelState = LevelState.GameOver;
                }

                //
                if (InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.A) ||
                    InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.B) ||
                    InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.X) ||
                    InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.Y) ||
                    InputHelper.WasKeyPressed(Keys.NumPad7) ||
                    InputHelper.WasKeyPressed(Keys.NumPad8))
                {
                    this.TimerContinue--;
                    SoundManager.PlaySound("PickUpItem");
                }

                // Has player pressed Start to continue
                //if (InputHelper.WasKeyPressed(Keys.Space))
                if (InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.Start) ||
                    InputHelper.WasKeyPressed(Keys.Enter) ||
                    InputHelper.WasKeyPressed(Keys.Space))
                {
                    SoundManager.PlaySound("CrashGlass");
                    SoundManager.PlaySound("CodyWins");
                    this.Player1.Continue();
                    this.LevelState = LevelState.Playing;
                }
                break;

                #endregion

                #region GameOver

            case LevelState.GameOver:
                // Has player pressed Start to continue
                //if (InputHelper.WasKeyPressed(Keys.Space))
                if (InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.Start) ||
                    InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.A) ||
                    InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.B) ||
                    InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.X) ||
                    InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.Y) ||
                    InputHelper.WasKeyPressed(Keys.Space) ||
                    InputHelper.WasKeyPressed(Keys.Enter))
                {
                    SoundManager.PlaySound("CrashGlass");
                    SoundManager.PlaySound("CodyWins");
                    GameManager.GameState = GameState.MainMenu;
                }

                break;

                #endregion

                #region Completed Game
            case LevelState.Completed:

                if (InputHelper.WasKeyPressed(Keys.Space) ||
                    InputHelper.WasKeyPressed(Keys.Enter) ||
                    InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.A) ||
                    InputHelper.WasButtonPressed(PlayerIndex.One, Buttons.Start))
                {
                    GameManager.GameState = GameState.MainMenu;
                    MusicManager.PlaySong(Game1.MusicTitleScreen);
                    SoundManager.PlaySound("CrashGlass");
                    SoundManager.PlaySound("GetOutOfMyFace");
                    MusicManager.ChangeToVolume(MusicManager.CurrentVolume);
                }


                break;

                #endregion

                #region FadeIn
            case LevelState.FadeIn:
                HUDManager.Opacity -= 0.008f;
                if (HUDManager.Opacity <= 0)
                {
                    HUDManager.Opacity = 0;
                    LevelState         = LevelState.Intro;
                }
                break;


                #endregion

                #region FadeOut
            case LevelState.FadeOut:

                HUDManager.Opacity += 0.008f;
                if (HUDManager.Opacity >= 1f)
                {
                    HUDManager.Opacity = 1;
                    GameManager.GoToNextLevel();
                }
                break;



                #endregion
            }
        }