Esempio n. 1
0
        private void LoadNextLevel()
        {
            // move to the next level
            levelIndex = (levelIndex + 1) % numberOfLevels;

            // Unloads the content for the current level before loading the next one.
            if (level != null)
            {
                level.Dispose();
            }

            // Load the level.
            string levelPath      = string.Format("Content/Levels/build/{0}.txt", levelIndex);
            string levelPathDebug = string.Format("Content/Levels/indev/dev_01.txt", levelIndex);

            string levelToLoad;

            if (Platformer.Program.debugmode)
            {
                levelToLoad = levelPathDebug;
            }
            else
            {
                levelToLoad = levelPath;
            }

            using (Stream fileStream = TitleContainer.OpenStream(levelToLoad))
                level = new Level(Services, fileStream, levelIndex);
        }
Esempio n. 2
0
        private void LoadNextLevel()
        {
            // move to the next level
            if (levelIndex + 1 == numberOfLevels)
            {
                LoadingScreen.Load(ScreenManager, true, PlayerIndex.One,
                                   new EndScreen());
                //return;
            }

            levelIndex = (levelIndex + 1) % numberOfLevels;

            // Unloads the content for the current level before loading the next one.
            if (level != null)
            {
                level.Dispose();
            }

            // Load the level.
            string levelPath = string.Format("Content/Levels/{0}.txt", levelIndex);

            using (Stream fileStream = TitleContainer.OpenStream(levelPath))
            {
                if (Global.IsLoaded)
                {
                    level = new Level(serviceProvider, fileStream, Global.ActualLevel, Global.Score, Global.Lives);

                    Global.IsLoaded = false;
                }
                else
                {
                    level = new Level(serviceProvider, fileStream, levelIndex, score, lives);
                }
            }
        }
Esempio n. 3
0
        private void LoadNextLevel()
        {
            // move to the next level
            levelIndex = (levelIndex + 1) % numberOfLevels;
            //levelIndex = 1;		// TODO remove this override - could make this configurable...!
            // Unloads the content for the current level before loading the next one.
            if (level != null)
                level.Dispose();

            // Load the level.
            string levelPath = string.Format("Content/Levels/{0}.txt", levelIndex);
            using (Stream fileStream = TitleContainer.OpenStream(levelPath))
                level = new Level(Services, fileStream, levelIndex);
        }
Esempio n. 4
0
        private void LoadNextLevel()
        {
            // move to the next level
            levelIndex = (levelIndex + 1) % levelsData.Count;

            // Unloads the content for the current level before loading the next one.
            if (currentLevel != null)
            {
                currentLevel.Dispose();
            }

            // Load the level.
            currentLevel = new Level(Services, levelsData[levelIndex]);
        }
Esempio n. 5
0
        private void LoadNextLevel()
        {
            // move to the next level
            levelIndex = (levelIndex + 1) % numberOfLevels;

            // Unloads the content for the current level before loading the next one.
            if (level != null)
            {
                level.Dispose();
            }

            // Load the level.
            string levelPath = string.Format("{0}/Levels/{1}.txt", Content.RootDirectory, levelIndex);

            using (Stream fileStream = TitleContainer.OpenStream(levelPath))
                level = new Level(Services, fileStream, levelIndex);
        }
        private void LoadNextLevel()
        {
            // move to the next level
            levelIndex = (levelIndex + 1) % numberOfLevels;

            // Unloads the content for the current level before loading the next one.
            if (level != null)
            {
                level.Dispose();
            }
            // Load the level
            string levelPath = string.Format("Content/Levels/{0}.txt", levelIndex);

            using (Stream fileStream = TitleContainer.OpenStream(levelPath))
                level = new Level(Services, fileStream, levelIndex);


            commandManager.ClearBindings();
            InitializeBindings();
        }
Esempio n. 7
0
        private void LoadNextLevel()
        {
            // Find the path of the next level.
            string levelPath;

            // Loop here so we can try again when we can't find a level.
            while (true)
            {
                // Try to find the next level. They are sequentially numbered txt files.
                #if IPHONE
                levelPath = String.Format("Content/Levels/{0}.txt", ++levelIndex);
                                #else
                levelPath = String.Format("Levels/{0}.txt", ++levelIndex);
                levelPath = Path.Combine(StorageContainer.TitleLocation, "Content/" + levelPath);
                                #endif
                if (File.Exists(levelPath))
                {
                    break;
                }

                // If there isn't even a level 0, something has gone wrong.
                if (levelIndex == 0)
                {
                    throw new Exception("No levels found.");
                }

                // Whenever we can't find a level, start over again at 0.
                levelIndex = -1;
            }

            // Unloads the content for the current level before loading the next one.
            if (level != null)
            {
                level.Dispose();
            }

            // Load the level.
            level = new Level(Services, levelPath);
        }
Esempio n. 8
0
        private void LoadNextLevel()
        {
            // move to the next level
            if (level != null)
            {
                levelIndex = (PlatformerGame.attacker_id == 0) ? (levelIndex + 1) % numberOfLevels : (levelIndex - 1) % numberOfLevels;
            }
            else
            {
                levelIndex = (levelIndex + 1) % numberOfLevels;
            }

            // Provide the background set
            string[] backgroundSet = new string[3] {
                "Backgrounds/Background0_0", "Backgrounds/Background0_1", "Backgrounds/Background0_2"
            };
            switch (levelIndex)
            {
            case 2:
            case 4:
                backgroundSet[0] = "Backgrounds/Background1_0";
                backgroundSet[1] = "Backgrounds/Background1_1";
                backgroundSet[2] = "Backgrounds/Background1_2";
                break;

            case 3:
                backgroundSet[0] = "Backgrounds/Background0_0";
                backgroundSet[1] = "Backgrounds/Background0_1";
                backgroundSet[2] = "Backgrounds/Background0_2";
                break;

            case 1:
            case 5:
                backgroundSet[0] = "Backgrounds/Background2_0";
                backgroundSet[1] = "Backgrounds/Background2_1";
                backgroundSet[2] = "Backgrounds/Background2_2";
                break;

            case 0:
            case 6:
                backgroundSet[0] = null;
                backgroundSet[1] = null;
                backgroundSet[2] = null;
                break;
            }

            //If the either reaches the last level, remove the other player
            if (levelIndex == 6 || levelIndex == 0)
            {
                int idx = (attacker_id == 0) ? 1 : 0;
                Players[idx].IsRespawnable = false;
                Players[idx].Reset(Vector2.Zero);
                bossFight = true;
                try
                {
                    MediaPlayer.Stop();
                    MediaPlayer.Play(content.Load <Song>("Sounds/Music/smb-castle"));
                }
                catch { }
            }


            // Unloads the content for the current level before loading the next one.
            if (level != null)
            {
                foreach (Player player in PlatformerGame.Players)
                {
                    player.OnHit        -= player_OnHit;
                    player.IsRespawnable = true;
                }
                level.Dispose();
            }

            // Load the level.
            string levelPath = string.Format("Content/Levels/{0}.txt", levelIndex);

            using (Stream fileStream = TitleContainer.OpenStream(levelPath)) {
                level = new Level(ScreenManager.Game.Services, fileStream, levelIndex, backgroundSet, this);
                foreach (Player player in PlatformerGame.Players)
                {
                    player.OnHit += new OnHitHandler(player_OnHit);
                }
            }

            startLevelDelayTimer = true;
        }