ctac.MapService.GetCrossTiles C# (CSharp) Method

GetCrossTiles() public method

public GetCrossTiles ( Vector2 center, int distance ) : Tile>.Dictionary
center Vector2
distance int
return Tile>.Dictionary
        public Dictionary<Vector2, Tile> GetCrossTiles(Vector2 center, int distance)
        {
            var ret = new Dictionary<Vector2, Tile>()
            {
                { center, mapModel.tiles.Get(center) }
            };
            Tile neighborTile = null;
            for (var d = 1; d <= distance; d++)
            {
                var toCheck = new Vector2[4] {
                  center.AddX(d),
                  center.AddX(-d),
                  center.AddY(d),
                  center.AddY(-d)
                };

                foreach (var currentDirection in toCheck)
                {
                    //check it's not off the map
                    neighborTile = mapModel.tiles.Get(currentDirection);
                    if (neighborTile != null)
                    {
                        ret[currentDirection] = neighborTile;
                    }
                }
            }
            return ret;
        }