Beispiel #1
0
        /// <summary>
        /// Constructs a new level.
        /// </summary>
        /// <param name="serviceProvider">
        /// The service provider that will be used to construct a ContentManager.
        /// </param>
        /// <param name="path">
        /// The absolute path to the level file to be loaded.
        /// </param>
        public Level(IServiceProvider serviceProvider, string path, int score, int pHP, int pMaxHP)
        {
            // Create a new content manager to load content used just by this level.
            ContentManager = new ContentManager(serviceProvider, "Content");
            Content = new ContentLoader(this);

            timeRemaining = TimeSpan.FromMinutes(1.0);

            NextLevel = null;
            LoadTiles(path, pHP, pMaxHP);
            levelSize = new Rectangle(0, 0, Width * Tile.Width, Height * Tile.Height);

            // Load background layer textures. For now, all levels must
            // use the same backgrounds and only use the left-most part of them.
            layers = new Layer[3];
            layers[0] = new Layer(Content, "Backgrounds/Layer0", 0.2f);
            layers[1] = new Layer(Content, "Backgrounds/Layer1", 0.5f);
            layers[2] = new Layer(Content, "Backgrounds/Layer2", 0.8f);

            // Load sounds.
            this.score = score;
            exitReachedSound = Content.LoadSoundEffect("Sounds/ExitReached");
        }