RoomManager.getBiome C# (CSharp) Method

getBiome() private method

private getBiome ( int x, int y ) : void
x int
y int
return void
    private void getBiome(int x, int y)
    {
        if (this.tileMap[x, y] != null) {
            return;
        }

        int distance = 1000;
        int closestIndex = 0;
        for (int regionI = 0; regionI < this.regions.Count; regionI++) {
            Region region = this.regions[regionI];

            int dist = (int) (Mathf.Abs(region.focusX - x) + Mathf.Abs(region.focusY - y));
            if (dist < distance) {
                closestIndex = regionI;
                distance = dist;
            }
        }

        Region closest = this.regions[closestIndex];
        tileMap[x, y] = new Tile (x, y, closestIndex, closest.biome.getBiomeNumber(), false, closest.altitude);
        this.regions[closestIndex].tiles.Add(tileMap[x, y]);
    }