Ejemplo n.º 1
0
 public SpriteGrid(SpriteGridSettings settings) {
     Columns = settings.Columns;
     Rows = settings.Rows;
     Texture = settings.Texture;
     SpriteBatch = settings.SpriteBatch;
     Layer = settings.Layer;
 }
Ejemplo n.º 2
0
        void CreateTheDungeon(SpriteBatch spriteBatch) {
            _dungeon = Entity.Create(Entities.Game.Dungeon,
                new Transformable2D() {
                    Position = new Vector2(
                        -(GameContext.Bounds.Width / 2),
                        -(GameContext.Bounds.Height / 2))
                });

            SpriteGridSettings gridSettings =
                new SpriteGridSettings() {
                    SpriteBatch = spriteBatch,
                    Columns = DungeonColumns,
                    Rows = DungeonRows
                };

            gridSettings.Layer = 0;

            Entity.Create(Entities.Game.DungeonFloor,
                new Transformable2D() {
                    Parent = _dungeon.GetComponent<Transformable2D>()
                },
                new SpriteGrid(gridSettings) {
                    Texture = Texture.FromFile("Content/Graphics/floor.png")
                }
            );

            string dungeonWallsMap =
                "11111011111" +
                "10000000001" +
                "10000000001" +
                "10000000001" +
                "10001000001" +
                "10001000001" +
                "10111110001" +
                "10001100001" +
                "10002000001" +
                "10000000001" +
                "10000000011" +
                "10000021111" +
                "10000000011" +
                "10000000001" +
                "10000000021" +
                "11000000011";

            gridSettings.Layer = 1;

            Entity.Create(Entities.Game.DungeonWalls,
                new Transformable2D() {
                    Parent = _dungeon.GetComponent<Transformable2D>()
                },
                new MappedSpriteGrid(gridSettings, dungeonWallsMap) {
                    Textures = new Texture[] { 
                        Texture.FromFile("Content/Graphics/wall.png"),       // #1
                        Texture.FromFile("Content/Graphics/wall-broken.png") // #2
                    }
                }
            );

            string dungeonEnemiesMap =
                "00000000000" +
                "00001111000" +
                "00000100000" +
                "00000000000" +
                "00010000000" +
                "00000010000" +
                "01000000000" +
                "01100010000" +
                "00000100000" +
                "00011100000" +
                "00000000000" +
                "00000000000" +
                "00000001100" +
                "00000000000" +
                "00000000000" +
                "00000000000";

            Entity.Create(Entities.Game.DungeonEnemies,
                new Transformable2D() {
                    Parent = _dungeon.GetComponent<Transformable2D>()
                },
                new MappedSpriteGrid(gridSettings, dungeonEnemiesMap) {
                    Texture = Texture.FromFile("Content/Graphics/enemy.png")
                }
            );
        }