Exemplo n.º 1
0
        public Level(IServiceProvider serviceProvider, Stream fileStream, int levelIndex)
        {
            // Create a new content manager to load content used just by this level.
            content = new ContentManager(serviceProvider, "Content");

            timeRemaining = TimeSpan.FromMinutes(2.0);

            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];
            layers[0] = new Layer(Content, "Backgrounds/background", 0.2f);
            layers[1] = new Layer(Content, "Backgrounds/background", 0.5f);
            layers[2] = new Layer(Content, "Backgrounds/background", 0.8f);
            /*layers = new Texture2D[3];
             *
            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.
        }
Exemplo n.º 2
0
        public Level(IServiceProvider serviceProvider, Stream fileStream, int levelIndex)
        {
            Content = new ContentManager(serviceProvider, "Content");

            TimeRemaining = TimeSpan.FromMinutes(3.0);

            LoadTiles(fileStream);

            layer = new Layer(Content, "Backgrounds/bg", 0.5f);

            /*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);*/

            exitReachedSound = Content.Load<SoundEffect>("Sounds/ExitReached");
        }
Exemplo n.º 3
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");
            }
        }
Exemplo n.º 4
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)
        {
            // Create a new content manager to load content used just by this level.
            content = new ContentManager(serviceProvider, "Content");

            timeRemaining = TimeSpan.FromMinutes(2.0);

            LoadTiles(fileStream);

            // Load background layer textures.  
            //The third value passed to the layer constructor is the scroll speed.
            //0 represents no scrolling 1.0 represents scrolling at the same speed the foreground moves at.
            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.
            exitReachedSound = Content.Load<SoundEffect>("Sounds/ExitReached");
        }