Beispiel #1
0
        public void SwitchToNextLevel()
        {
            currentLevel++;
            if (currentLevel > TOTAL_LEVELS)
            {
                currentLevel = 1;
            }
            //currentLevel = currentLevel % LevelList.Count;
            //activeLevel = (LevelData)LevelList.ToArray()[currentLevel];
            //activeLevel.startLevel(ScreenManager.Game);

            if (activeLevel != null)
            {
                activeLevel.clearLevel(ScreenManager.Game);
                activeLevel = null;
            }
            switch (currentLevel)
            {
            case 1:
                activeLevel = new Level1(ScreenManager.Game, this);
                break;

            case 2:
                activeLevel = new Level2(ScreenManager.Game, this);
                break;

            case 3:
                activeLevel = new Level3(ScreenManager.Game, this);
                break;

            case 4:
                activeLevel = new Level4(ScreenManager.Game, this);
                break;

            case 5:
                activeLevel = new Level5(ScreenManager.Game, this);
                break;

            default:
                break;
            }
            activeLevel.startLevel(ScreenManager.Game);


            player.position      = activeLevel.startingLocation;
            player.velocity      = Vector3.Zero;
            player.netForce      = Vector3.Zero;
            manualCameraRotation = 0.0f;
            ScreenManager.Game.Components.Add(player);
            m_kCountdownTimer = new Utils.CountdownTimer(ScreenManager.Game, new Vector2(875.0f, 20.0f));
            m_kScoreKeeper    = new Utils.ScoreKeeper(ScreenManager.Game, new Vector2(20f, 20f));
            m_kScoreKeeper.setScore(score);
            ScreenManager.Game.Components.Add(m_kCountdownTimer);
            ScreenManager.Game.Components.Add(m_kScoreKeeper);
            ScreenManager.Game.Components.Add(sky);
        }
Beispiel #2
0
        public void RestartLevel()
        {
            UnloadContent();
            //activeLevel = (LevelData)LevelList.ToArray()[currentLevel];
            activeLevel.startLevel(ScreenManager.Game);

            player.position = activeLevel.startingLocation;
            player.velocity = Vector3.Zero;
            player.netForce = Vector3.Zero;

            ScreenManager.Game.Components.Add(player);
            m_kCountdownTimer = new Utils.CountdownTimer(ScreenManager.Game, new Vector2(875.0f, 20.0f));
            m_kScoreKeeper    = new Utils.ScoreKeeper(ScreenManager.Game, new Vector2(20f, 20f));
            m_kScoreKeeper.setScore(score);
            ScreenManager.Game.Components.Add(m_kCountdownTimer);
            ScreenManager.Game.Components.Add(m_kScoreKeeper);
            ScreenManager.Game.Components.Add(sky);
            manualCameraRotation = 0.0f;
        }
Beispiel #3
0
        /// <summary>
        /// Updates the state of the game. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                    bool coveredByOtherScreen)
        {
            if (IsActive)
            {
                //gameCamera.followBehind(player);

                activeLevel.MovePlayer(player, gameTime);

                //fell off the stage
                //reset player position when fallen off
                if (player.position.Y < activeLevel.DeathBound)
                {
                    RestartLevel();
                }


                //hit the goal
                if (activeLevel.IsCollidingWithGoal(player))
                {
                    UnloadContent();
                    soundbank.PlayCue("zing");
                    SwitchToNextLevel();
                }
                if (activeLevel.IsCollidingWithCollectable(player, ScreenManager.Game))
                {
                    score++;
                    m_kScoreKeeper.setScore(score);
                }
                if (m_kCountdownTimer.getRemainingTime() == 0 && !IsTesting)
                {
                    RestartLevel();
                }
                //realign camera position
                m_kLookingDir   = player.position - gameCamera.GetCameraPosition();
                m_kLookingDir.Y = 0f;
                m_kLookingDir.Normalize();
            }


            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }
        public void SwitchToNextLevel()
        {
            currentLevel++;
            if (currentLevel > TOTAL_LEVELS) {
                currentLevel = 1;
            }
            //currentLevel = currentLevel % LevelList.Count;
            //activeLevel = (LevelData)LevelList.ToArray()[currentLevel];
            //activeLevel.startLevel(ScreenManager.Game);

            if (activeLevel != null)
            {

                activeLevel.clearLevel(ScreenManager.Game);
                activeLevel = null;
            }
            switch (currentLevel) {
                case 1:
                    activeLevel = new Level1(ScreenManager.Game, this);
                    break;
                case 2:
                    activeLevel = new Level2(ScreenManager.Game, this);
                    break;
                case 3:
                    activeLevel = new Level3(ScreenManager.Game, this);
                    break;
                case 4:
                    activeLevel = new Level4(ScreenManager.Game, this);
                    break;
                case 5:
                    activeLevel = new Level5(ScreenManager.Game, this);
                    break;
                default:
                    break;
            }
            activeLevel.startLevel(ScreenManager.Game);

            player.position = activeLevel.startingLocation;
            player.velocity = Vector3.Zero;
            player.netForce = Vector3.Zero;
            manualCameraRotation = 0.0f;
            ScreenManager.Game.Components.Add(player);
            m_kCountdownTimer = new Utils.CountdownTimer(ScreenManager.Game, new Vector2(875.0f, 20.0f));
            m_kScoreKeeper = new Utils.ScoreKeeper(ScreenManager.Game, new Vector2(20f, 20f));
            m_kScoreKeeper.setScore(score);
            ScreenManager.Game.Components.Add(m_kCountdownTimer);
            ScreenManager.Game.Components.Add(m_kScoreKeeper);
            ScreenManager.Game.Components.Add(sky);
        }
        public void RestartLevel()
        {
            UnloadContent();
            //activeLevel = (LevelData)LevelList.ToArray()[currentLevel];
            activeLevel.startLevel(ScreenManager.Game);

            player.position = activeLevel.startingLocation;
            player.velocity = Vector3.Zero;
            player.netForce = Vector3.Zero;

            ScreenManager.Game.Components.Add(player);
            m_kCountdownTimer = new Utils.CountdownTimer(ScreenManager.Game, new Vector2(875.0f, 20.0f));
            m_kScoreKeeper = new Utils.ScoreKeeper(ScreenManager.Game, new Vector2(20f, 20f));
            m_kScoreKeeper.setScore(score);
            ScreenManager.Game.Components.Add(m_kCountdownTimer);
            ScreenManager.Game.Components.Add(m_kScoreKeeper);
            ScreenManager.Game.Components.Add(sky);
            manualCameraRotation = 0.0f;
        }