public TileBase[,] BuildCorridor(Vector2Int corridorStart, Vector2Int corridorEnd, Dir dir) { Dictionary <string, TileBase> tileDict = TileLoader.LoadCorridor("Color", 1); TileBase[,] corridor; bool hor = false; switch (dir) { case Dir.LEFT: case Dir.RIGHT: corridor = new TileBase[Math.Abs(corridorEnd.x - corridorStart.x), 2 + corridorWidth]; hor = true; break; case Dir.UP: case Dir.DOWN: corridor = new TileBase[2 + corridorWidth, Math.Abs(corridorEnd.y - corridorStart.y)]; hor = false; break; default: corridor = new TileBase[0, 0]; break; } int width = corridor.GetLength(0); int height = corridor.GetLength(1); if (hor) { for (int x = 0; x < width; x++) { for (int y = 0; y < 2 + corridorWidth; y++) { if (x == 0) { if (y == 0) { corridor[x, y] = tileDict["horBotLeft"]; } else if (y == 1 + corridorWidth) { corridor[x, y] = tileDict["horTopLeft"]; } } else if (x == width - 1) { if (y == 0) { corridor[x, y] = tileDict["horBotRight"]; } else if (y == 1 + corridorWidth) { corridor[x, y] = tileDict["horTopRight"]; } } else { if (y == 0) { corridor[x, y] = tileDict["top"]; } else if (y == 1 + corridorWidth) { corridor[x, y] = tileDict["bot"]; } } } } } else { for (int x = 0; x < 2 + corridorWidth; x++) { for (int y = 0; y < height; y++) { if (y == 0) { if (x == 0) { corridor[x, y] = tileDict["vertBotLeft"]; } else if (x == 1 + corridorWidth) { corridor[x, y] = tileDict["vertBotRight"]; } } else if (y == height - 1) { if (x == 0) { corridor[x, y] = tileDict["vertTopLeft"]; } else if (x == 1 + corridorWidth) { corridor[x, y] = tileDict["vertTopRight"]; } } else { if (x == 0) { corridor[x, y] = tileDict["right"]; } else if (x == 1 + corridorWidth) { corridor[x, y] = tileDict["left"]; } } } } } return(corridor); }