コード例 #1
0
        public static void loadLevel(int levelNumber)
        {
            EnemyManager.clear();
            PickUpManager.clear();
            if (levelNumber != m_LevelNumber)
            {
                m_LevelNumber = levelNumber;
            }
            //TODO: call enemy manager clear
            BackgroundMusic.playSong(levelNumber, 0.30f);
            string level = "Content/Level" + levelNumber + ".txt";

            parseData(level);
            if (levelNumber >= 3)
            {
                Background.loadContent(Content, 3, 1);
            }
            else
            {
                Background.loadContent(Content, levelNumber + 1, 1);
            }
            if (levelNumber == 3)
            {
                Boss.IsActive = true;;
            }
            Player.reset();
            Player.setInitialPosition();
            EnemyManager.loadContent(Content);
            GateManager.reset();
            GateManager.loadContent(Content);
            PickUpManager.loadContent(Content);
        }
コード例 #2
0
ファイル: Gate.cs プロジェクト: ZaikMD/TaleOfTwoHorns
        public override void  update(GameTime gameTime)
        {
            base.update(gameTime);

            if (CollisionCheck.collisionCheck(Player.collisionRectangle(), Destination))
            {
                if (Player.m_hasKey == true)
                {
                    Player.m_hasKey = false;
                    m_ScreenManager.CurrentGameState = GameState.LevelComplete;
                    Player.reset();
                    Player.setInitialPosition();
                    Level.levelIncrement();
                }
            }
        }
コード例 #3
0
        public void Update(GameTime gameTime, Game game)
        {
            MouseState    mouse    = Mouse.GetState();
            KeyboardState keyboard = Keyboard.GetState();
            GamePadState  gamepad  = GamePad.GetState(PlayerIndex.One, GamePadDeadZone.None);

            switch (CurrentGameState)
            {
            case GameState.SplashScreen:
                if (keyboard.IsKeyDown(Keys.Space) || m_ButtonSpace.isClicked == true || gamepad.IsButtonDown(Buttons.Start))
                {
                    currentGameState = GameState.MainMenu;
                }
                m_ButtonSpace.Update(mouse);
                break;

            case GameState.MainMenu:
                if (m_ButtonPlay.isClicked == true || gamepad.IsButtonDown(Buttons.A) && m_ButtonDown == false)
                {
                    m_ButtonDown = true;
                    //  Level.loadLevel(0);

                    currentGameState = GameState.Game;
                }
                else if (gamepad.IsButtonUp(Buttons.A))
                {
                    m_ButtonDown = false;
                }
                m_ButtonPlay.Update(mouse);
                if (m_ButtonCredits.isClicked == true || gamepad.IsButtonDown(Buttons.X) && m_ButtonDown == false)
                {
                    m_ButtonDown     = true;
                    currentGameState = GameState.Credits;
                }
                else if (gamepad.IsButtonUp(Buttons.X))
                {
                    m_ButtonDown = false;
                }
                m_ButtonCredits.Update(mouse);
                if (m_ButtonLevelSelect.isClicked == true || gamepad.IsButtonDown(Buttons.Y) && m_ButtonDown == false)
                {
                    m_ButtonDown     = true;
                    currentGameState = GameState.LevelSelect;
                }
                else if (gamepad.IsButtonUp(Buttons.Y))
                {
                    m_ButtonDown = false;
                }
                m_ButtonLevelSelect.Update(mouse);
                if (m_ButtonExit.isClicked == true || gamepad.IsButtonDown(Buttons.Back) && m_ButtonDown == false)
                {
                    m_ButtonDown = true;
                    game.Exit();
                }
                else if (gamepad.IsButtonUp(Buttons.Back))
                {
                    m_ButtonDown = false;
                }
                m_ButtonExit.Update(mouse);
                break;

            case GameState.Credits:
                if (m_ButtonBack.isClicked == true || gamepad.IsButtonDown(Buttons.B) && m_ButtonDown == false)
                {
                    m_ButtonDown     = true;
                    CurrentGameState = GameState.MainMenu;
                }
                else if (gamepad.IsButtonDown(Buttons.B))
                {
                    m_ButtonDown = false;
                }
                m_ButtonBack.Update(mouse);
                break;

            case GameState.LevelSelect:
                if (m_LevelOne.isClicked == true || gamepad.IsButtonDown(Buttons.A) && m_ButtonDown == false)
                {
                    m_ButtonDown = true;
                    Level.loadLevel(0);
                    CurrentGameState = GameState.Game;
                }
                else if (gamepad.IsButtonDown(Buttons.A))
                {
                    m_ButtonDown = false;
                }
                m_LevelOne.Update(mouse);
                if (m_LevelTwo.isClicked == true || gamepad.IsButtonDown(Buttons.X) && m_ButtonDown == false)
                {
                    m_ButtonDown = true;
                    Level.loadLevel(1);
                    CurrentGameState = GameState.Game;
                }
                m_LevelTwo.Update(mouse);
                if (m_LevelThree.isClicked == true || gamepad.IsButtonDown(Buttons.Y) && m_ButtonDown == false)
                {
                    m_ButtonDown = true;
                    Level.loadLevel(2);
                    CurrentGameState = GameState.Game;
                }
                m_LevelThree.Update(mouse);
                if (m_ButtonBack.isClicked == true)
                {
                    //m_ButtonDown = false;
                    CurrentGameState = GameState.MainMenu;
                }
                m_ButtonBack.Update(mouse);
                if (m_Boss.isClicked == true || gamepad.IsButtonDown(Buttons.B) && m_ButtonDown == false)
                {
                    m_ButtonDown = true;
                    Level.loadLevel(3);
                    CurrentGameState = GameState.Game;
                }
                m_Boss.Update(mouse);
                break;

            case GameState.LevelComplete:
                if (m_NextLevel.isClicked == true)
                {
                    CurrentGameState = GameState.Game;
                }
                m_NextLevel.Update(mouse);
                break;

            case GameState.GameOver:
                if (keyboard.IsKeyDown(Keys.Escape) || gamepad.IsButtonDown(Buttons.B) && m_ButtonDown == false)
                {
                    m_ButtonDown     = true;
                    CurrentGameState = GameState.MainMenu;
                }
                if (keyboard.IsKeyDown(Keys.R) && m_ButtonDown == false || gamepad.IsButtonDown(Buttons.B) && m_ButtonDown == false)
                {
                    m_ButtonDown     = true;
                    CurrentGameState = GameState.Game;
                    EndPause();
                }
                break;

            case GameState.PauseMenu:
                if (keyboard.IsKeyDown(Keys.Escape) || gamepad.IsButtonDown(Buttons.Back) && m_ButtonDown == false)
                {
                    Player.reset();
                    m_ButtonDown     = true;
                    CurrentGameState = GameState.MainMenu;
                }
                else if (keyboard.IsKeyDown(Keys.Escape))
                {
                    m_ButtonDown = false;
                }
                else if (gamepad.IsButtonDown(Buttons.Back))
                {
                    m_ButtonDown = false;
                }
                if (keyboard.IsKeyDown(Keys.Space) || gamepad.IsButtonDown(Buttons.B) && m_ButtonDown == false)
                {
                    m_ButtonDown     = true;
                    CurrentGameState = GameState.Game;
                }
                break;

            case GameState.Game:
                if (keyboard.IsKeyDown(Keys.P) || gamepad.IsButtonDown(Buttons.Start) && m_ButtonDown == false)
                {
                    m_ButtonDown     = true;
                    CurrentGameState = GameState.PauseMenu;
                    BeginPause();
                }
                break;
            }
        }