Beispiel #1
0
        public static void GoToNextLevel()
        {
            CurrentLevel++;

            HUDManager.setLevel(Levels[CurrentLevel]);

            // Copy the needed details cross to the next level
            // Set the Player1 to the same Player1 as the last level
            Levels[CurrentLevel].Player1 = Levels[CurrentLevel - 1].Player1;
            // Make sure the Player1 is in the new Actor's list
            Levels[CurrentLevel].Actors.Add(Levels[CurrentLevel].Player1);
            // Set player1's inLevel
            Levels[CurrentLevel].Player1.InLevel = Levels[CurrentLevel];

            // Reset Player1 Draw details
            Levels[CurrentLevel].Player1.ResetIdleGraphic();

            Levels[CurrentLevel].Player1.Health   = 300; // Maybe leave energy the same
            Levels[CurrentLevel].Player1.Position = new Vector2(-100, 440);
            Levels[CurrentLevel].Player1.SetIntro01TargetPosition(new Vector2(425, 520));
            Levels[CurrentLevel].Player1.State = PlayerState.Level01Intro;

            Levels[CurrentLevel].LevelState = LevelState.FadeIn;
            Camera.Position = new Vector2(Game1.SCREEN_WIDTH / 2, Game1.SCREEN_HEIGHT / 2);

            if (CurrentLevel == 2) // If Level 2 play Lvl 2 music
            {
                MusicManager.StopSong();
                MusicManager.PlaySong("music02");
            }
        }
        public static void CreateMenuItems()
        {
            menuItems.Add(new MenuItem("Begin Game", new Vector2(45, 50)));
            menuItems.Add(new MenuItem("How To Play", new Vector2(45, 120)));
            menuItems.Add(new MenuItem("Exit Game", new Vector2(45, 190)));

            // Play Music
            MusicManager.StopSong();
            MusicManager.PlaySong("music02");
            MusicManager.SetRepeating(true);
        }
        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;
            }
        }