DungeonMasterEngine.Builders.LegacyMapBuilder.GetNeigbourTiles C# (CSharp) Method

GetNeigbourTiles() public method

public GetNeigbourTiles ( Point position, DungeonMap map ) : IEnumerable>
position Point
map DungeonMasterParser.DungeonMap
return IEnumerable>
        public IEnumerable<TileInfo<TileData>> GetNeigbourTiles(Point position, DungeonMap map)
        {
            return MapDirection.AllSides.Select(side =>
            {
                var p = position + side.RelativeShift;
                return new TileInfo<TileData>
                {
                    Position = p,
                    Tile = map[p.X, p.Y]
                };
            });
        }

Usage Example

Exemplo n.º 1
0
        private TileInfo <StairsTileData> FindStairs(Point pos, int level)
        {
            var map = builder.Data.Maps[level];

            var stairs = map[pos.X, pos.Y];

            if (stairs.GetType() == typeof(StairsTileData))
            {
                return(new TileInfo <StairsTileData> {
                    Position = pos, Tile = (StairsTileData)stairs
                });
            }
            else//TODO shouldnt be necesarry
            {
                var k = builder.GetNeigbourTiles(pos, map);

                var res = k.FirstOrDefault(x => x.Tile.GetType() == typeof(Stairs));
                if (res.Tile == null)
                {
                    throw new InvalidOperationException("Invalid CurrentMap format");
                }
                else
                {
                    return new TileInfo <StairsTileData> {
                               Position = res.Position, Tile = (StairsTileData)res.Tile
                    }
                };
            }
        }