Exemplo n.º 1
0
        public void SetUpLevel()
        {
            LevelPart nextLevelPart = levelAreas[0];

            levelAreas.Remove(0);
            enemies             = nextLevelPart.Enemies;
            entities            = nextLevelPart.Entities;
            layers              = nextLevelPart.Layers;
            marioPositions      = nextLevelPart.ExitPositions;
            Song                = nextLevelPart.Song;
            currentLevelSection = 0;
            entities.Insert(Stage.mario);
            InternalSaveLevel();
            SoundItems.SoundFactory.Instance.PlaySong(Song);
        }
Exemplo n.º 2
0
        public void GoToNewArea(int next, Camera camera)
        {
            entities.Remove(Stage.mario);
            //pack the current level part
            LevelPart levelPart = new LevelPart()
            {
                Enemies       = enemies,
                Layers        = layers,
                Entities      = entities,
                ExitPositions = marioPositions,
                Song          = Song
            };

            //put it in the dictionary
            levelAreas.Add(currentLevelSection, levelPart);
            //retrieve the new level area
            LevelPart nextLevelPart = levelAreas[next];

            //remove it
            levelAreas.Remove(next);
            //set up the properties
            enemies        = nextLevelPart.Enemies;
            entities       = nextLevelPart.Entities;
            layers         = nextLevelPart.Layers;
            marioPositions = nextLevelPart.ExitPositions;
            if (Song != nextLevelPart.Song)
            {
                SoundItems.SoundFactory.Instance.PlaySong(nextLevelPart.Song);
            }
            Song = nextLevelPart.Song;
            //give mario his new position
            Stage.mario.Position = marioPositions[currentLevelSection];
            Rectangle limits = entities.Bounds;

            //Set the height correctly as the blocks cover more height than the camera should.
            limits.Height -= 16;
            camera.Limits  = limits;
            camera.LookAt(Stage.mario.Position);
            currentLevelSection = next;
            entities.Insert(Stage.mario);
            InternalSaveLevel();
        }
Exemplo n.º 3
0
 public void AddArea(LevelPart levelPart, int order)
 {
     levelAreas.Add(order, levelPart);
 }