コード例 #1
0
 public Level(List <ParallaxElement> backgrounds, Vector2 playerStartPosition, List <TerrainElement> terrainElements, TerrainElement ground, List <Enemy> enemies, Rectangle playArea)
 {
     _backgrounds         = backgrounds;
     _playerStartPosition = playerStartPosition;
     _terrainElements     = terrainElements;
     _ground   = ground;
     _enemies  = enemies;
     _playArea = playArea;
 }
コード例 #2
0
        private static void LoadLevel1(ContentManager content)
        {
            Rectangle playArea = new Rectangle(0, 0, 3000, 720);

            Texture2D layer1 = content.Load <Texture2D>(@"Textures/Level1/Level1Layer1");
            Texture2D layer2 = content.Load <Texture2D>(@"Textures/Level1/Level1Layer2");
            Texture2D layer3 = content.Load <Texture2D>(@"Textures/Level1/Level1Layer3");
            Texture2D layer4 = content.Load <Texture2D>(@"Textures/Level1/Level1Layer4");
            Texture2D layer5 = content.Load <Texture2D>(@"Textures/Level1/Level1Layer5");

            List <ParallaxElement> backgrounds = new List <ParallaxElement>()
            {
                new ParallaxElement(layer1, Vector2.Zero, playArea, new Vector2(1f / 5f, 1f), Color.White),
                new ParallaxElement(layer2, Vector2.Zero, playArea, new Vector2(1f / 4f, 1f), Color.White),
                new ParallaxElement(layer3, Vector2.Zero, playArea, new Vector2(1f / 3f, 1f), Color.White),
                new ParallaxElement(layer4, Vector2.Zero, playArea, new Vector2(1f / 2f, 1f), Color.White),
                new ParallaxElement(layer5, Vector2.Zero, playArea, new Vector2(1f / 1.5f, 1f), Color.White),
            };


            Texture2D boxTexture    = content.Load <Texture2D>(@"Textures/Box");
            Texture2D barrelTexture = content.Load <Texture2D>(@"Textures/Barrel");

            Texture2D      groundTexture     = content.Load <Texture2D>(@"Textures/Ground");
            TerrainElement ground            = new TerrainElement(new CollidableObject(groundTexture, new Vector2(playArea.Left, playArea.Bottom - groundTexture.Height), new Rectangle(0, 0, playArea.Width, groundTexture.Height), 0.0f));
            int            groundStartHeight = playArea.Bottom - groundTexture.Height;

            List <TerrainElement> terrain = new List <TerrainElement>()
            {
                new TerrainElement(new CollidableObject(boxTexture, new Vector2(80, groundStartHeight - boxTexture.Height + 8)))
            };

            List <Enemy> enemies = new List <Enemy>()
            {
                new Pesant(new Vector2(300, groundStartHeight))
            };

            Vector2 playerStartPosition = new Vector2(100, groundStartHeight - 100);

            _levels.Add(new Level(backgrounds, playerStartPosition, terrain, ground, enemies, playArea));
        } // TODO
コード例 #3
0
        } // TODO

        private static void LoadLevel3(ContentManager content)
        {
            Rectangle playArea = new Rectangle(0, 0, 3000, 720);

            // Parallax background textures
            Texture2D layer1 = content.Load <Texture2D>(@"Textures/Level3/Layer1");
            Texture2D layer2 = content.Load <Texture2D>(@"Textures/Level3/Layer2");
            Texture2D layer3 = content.Load <Texture2D>(@"Textures/Level3/Layer3");
            Texture2D layer4 = content.Load <Texture2D>(@"Textures/Level3/Layer4");
            Texture2D layer5 = content.Load <Texture2D>(@"Textures/Level3/Layer5");

            List <ParallaxElement> backgrounds = new List <ParallaxElement>()
            {
                new ParallaxElement(layer1, Vector2.Zero, playArea, Vector2.One / 5f, Color.White),
                new ParallaxElement(layer2, Vector2.Zero, playArea, Vector2.One / 4f, Color.White),
                new ParallaxElement(layer3, Vector2.Zero, playArea, Vector2.One / 3f, Color.White),
                new ParallaxElement(layer4, Vector2.Zero, playArea, Vector2.One / 2f, Color.White),
                new ParallaxElement(layer5, Vector2.Zero, playArea, Vector2.One / 1.8f, Color.White),
            };

            Vector2 playerStartPosition = new Vector2(playArea.Center.X, 1000);


            List <TerrainElement> terrain = new List <TerrainElement>()
            {
            };

            Texture2D      groundTexture     = content.Load <Texture2D>(@"Textures/Ground");
            TerrainElement ground            = new TerrainElement(new CollidableObject(groundTexture, new Vector2(playArea.Left, playArea.Bottom - groundTexture.Height), new Rectangle(0, 0, playArea.Width, groundTexture.Height), 0.0f));
            int            groundStartHeight = playArea.Bottom - groundTexture.Height;

            Texture2D pesantTexture = content.Load <Texture2D>(@"Textures/Character");


            List <Enemy> enemies = new List <Enemy>()
            {
                new Pesant(new Vector2(100, groundStartHeight))
            };

            _levels.Add(new Level(backgrounds, playerStartPosition, terrain, ground, enemies, playArea));
        } // TODO
コード例 #4
0
 /// <summary>
 /// Sets InGame to this level
 /// </summary>
 /// <param name="playArea"></param>
 /// <param name="ground"></param>
 public void StartLevel(ref Rectangle playArea, ref List <TerrainElement> terrainElements, ref TerrainElement ground, ref List <Enemy> enemies, ref List <ParallaxElement> backgrounds, ref Vector2 playerPosition)
 {
     playArea        = _playArea;
     terrainElements = _terrainElements;
     ground          = _ground;
     enemies         = _enemies;
     backgrounds     = _backgrounds;
     playerPosition  = _playerStartPosition;
 }