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="fileStream">
        /// A stream containing the tile data.
        /// </param>
        public Level(IServiceProvider serviceProvider, Stream fileStream, int levelIndex, string[] backgroundSet, PlatformerGame game)
        {
            // Create a new content manager to load content used just by this level.
            content = new ContentManager(serviceProvider, "Content");

            this.game = game;

            timeRemaining = TimeSpan.FromMinutes(2.0);
            exit[0]       = InvalidPosition;
            exit[1]       = InvalidPosition;

            LoadTiles(fileStream);

            // 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];
            float scrollRate = 0.2f;

            for (int i = 0; i < layers.Length; ++i)
            {
                layers[i]   = new Layer(Content, backgroundSet[i], scrollRate);
                scrollRate += 0.3f;
            }

            /*
             * for (int i = 0; i < layers.Length; ++i)
             * {
             *  // Choose a random segment if each background layer for level variety.
             *  int segmentIndex = levelIndex;
             *  layers[i] = Content.Load<Texture2D>("Backgrounds/Layer" + i + "_" + segmentIndex);
             * }
             * */

            // Load sounds.
            fallingSound = Content.Load <SoundEffect>("Sounds/fallSound");
            clearSound   = Content.Load <SoundEffect>("Sounds/smb_stage_clear");
            bridgeSound  = content.Load <SoundEffect>("Sounds/bridgeSound");

            camera = new Camera2d(this, 0.0f);

            // allocate for corpses
            corpseIndex[0] = 0;
            corpseIndex[1] = 0;
            for (int i = 0; i < MAX_CORPSES; i++)
            {
                corpses[0, i] = new Corpse(this, Vector2.Zero, "Sprites/Player/blue_corpse");
                corpses[1, i] = new Corpse(this, Vector2.Zero, "Sprites/Player/yellow_corpse");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Constructs a new level.
        /// </summary>
        /// <param name="serviceProvider">
        /// The service provider that will be used to construct a ContentManager.
        /// </param>
        /// <param name="fileStream">
        /// A stream containing the tile data.
        /// </param>
        public Level(IServiceProvider serviceProvider, Stream fileStream, int levelIndex, string[] backgroundSet, PlatformerGame game)
        {
            // Create a new content manager to load content used just by this level.
            content = new ContentManager(serviceProvider, "Content");

            this.game = game;

            timeRemaining = TimeSpan.FromMinutes(2.0);
            exit[0] = InvalidPosition;
            exit[1] = InvalidPosition;

            LoadTiles(fileStream);

            // 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];
            float scrollRate = 0.2f;
            for (int i = 0; i < layers.Length; ++i)
            {
                layers[i] = new Layer(Content, backgroundSet[i], scrollRate);
                scrollRate += 0.3f;
            }
            /*
            for (int i = 0; i < layers.Length; ++i)
            {
                // Choose a random segment if each background layer for level variety.
                int segmentIndex = levelIndex;
                layers[i] = Content.Load<Texture2D>("Backgrounds/Layer" + i + "_" + segmentIndex);
            }
             * */

            // Load sounds.
            fallingSound = Content.Load<SoundEffect>("Sounds/fallSound");
            clearSound = Content.Load<SoundEffect>("Sounds/smb_stage_clear");
            bridgeSound = content.Load<SoundEffect>("Sounds/bridgeSound");

            camera = new Camera2d(this, 0.0f);

            // allocate for corpses
            corpseIndex[0] = 0;
            corpseIndex[1] = 0;
            for (int i = 0; i < MAX_CORPSES; i++)
            {
                corpses[0, i] = new Corpse(this, Vector2.Zero, "Sprites/Player/blue_corpse");
                corpses[1, i] = new Corpse(this, Vector2.Zero, "Sprites/Player/yellow_corpse");
            }
        }