示例#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;
            }
        }
        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
            }
        }