Esempio n. 1
0
        public static List<Enemy> getEnemyLayout(ContentManager content, string filename)
        {
            TileLayer tLayer = TileLayer.FromFile(content, filename);
            List<Enemy> enemyList = new List<Enemy>();

            int spawnMapWidth = tLayer.map.GetLength(1);
            int spawnMapHeight = tLayer.map.GetLength(0);

            for (int x = 0; x < spawnMapWidth; x++)
            {
                for (int y = 0; y < spawnMapHeight; y++)
                {
                    int textIndex = tLayer.map[y, x];

                    if (textIndex == 0)
                    {
                        continue;
                    }

                    if (textIndex == 1)
                    {
                        Enemy e = new Enemy(tLayer.tileTextures[textIndex - 1], new Vector2(x * tLayer.TileWidth, y * tLayer.TileHeight), EnemyType.normal, content);
                        enemyList.Add(e);
                    }

                    if (textIndex == 2)
                    {
                        Enemy e = new Enemy(tLayer.tileTextures[textIndex - 1], new Vector2(x * tLayer.TileWidth, y * tLayer.TileHeight), EnemyType.fast, content);
                        enemyList.Add(e);
                    }

                    if (textIndex == 3)
                    {
                        Enemy e = new Enemy(tLayer.tileTextures[textIndex - 1], new Vector2(x * tLayer.TileWidth, y * tLayer.TileHeight), EnemyType.projectile, content);
                        enemyList.Add(e);
                    }

                    if (textIndex == 4)
                    {
                        Enemy e = new Enemy(tLayer.tileTextures[textIndex - 1], new Vector2(x * tLayer.TileWidth, y * tLayer.TileHeight), EnemyType.boss, content);
                        enemyList.Add(e);
                    }

                }
            }

            return enemyList;
        }
Esempio n. 2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.

            spriteFont = Content.Load<SpriteFont>("SpriteFont1");

            enemyDeleteList = new List<Enemy>();
            bulletDeleteList = new List<Bullet>();
            eBulletDeleteList = new List<Bullet>();
            playerTexture = Content.Load<Texture2D>("manwalk");
            mouseTexture = Content.Load<Texture2D>("cursor");
            bulletTexture = Content.Load<Texture2D>("bullet2");

            enemyTexture = Content.Load<Texture2D>("ZombieGreen");
            //Texture2D enemyTexture2 = Content.Load<Texture2D>("ZombiePink");
            Texture2D enemyTexture3 = Content.Load<Texture2D>("ZombieRed");
            Texture2D enemyTexture4 = Content.Load<Texture2D>("ZombieOrange");
            enemyList = new List<Enemy>();

            int spawnMapWidth = spawnMap.GetLength(1);
            int spawnMapHeight = spawnMap.GetLength(0);

            for (int x = 0; x < spawnMapWidth; x++)
            {
                for (int y = 0; y < spawnMapHeight; y++)
                {
                    int textIndex = spawnMap[y, x];

                    if (textIndex == -1)
                    {
                        continue;
                    }

                    Enemy e = new Enemy(enemyTexture, new Vector2(x * tileWidth, y * tileHeight), Enemy.enemyType.normal);
                    enemyList.Add(e);

                }
            }

            //enemyList.Add(new Enemy(enemyTexture2, new Vector2(400, 400)));
            //enemyList.Add(new Enemy(enemyTexture3, new Vector2(500, 400)));
            enemyList.Add(new Enemy(enemyTexture4, new Vector2(600, 400),Enemy.enemyType.projectile, Content));
            enemyList.Add(new Enemy(enemyTexture3, new Vector2(500, 400), Enemy.enemyType.boss, Content));
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TILE STUFF

            tileDirt = Content.Load<Texture2D>("Tiles/se_free_dirt_texture");
            tileGrass = Content.Load<Texture2D>("Tiles/se_free_grass_texture");
            tileGround = Content.Load<Texture2D>("Tiles/se_free_ground_texture");
            tileMud = Content.Load<Texture2D>("Tiles/se_free_mud_texture");

            tileList.Add(tileDirt);
            tileList.Add(tileMud);
            tileList.Add(tileGround);
            tileList.Add(tileGrass);

            Texture2D tileHeart = Content.Load <Texture2D>("1up");
            tileHand = Content.Load<Texture2D>("crate");
            tileList2.Add(tileHand);
            tileList2.Add(tileHeart);

            player = new Player(playerTexture, mouseTexture, new Vector2(200, 200), new AnimatedSprite(playerTexture, 1, 2, 0.5f), Content);
            heart = Content.Load<Texture2D>("1up");
        }