//checks if a position on map is valid for door placement //and if so places the correct, randomized doords from sent prefabs private void TryPlaceDoor(Map map, GameObject[,] wallLayerTiles, GameObject[] horizontalDoorPrefabs, GameObject[] verticalDoorPrefabs, Coords2 coords) { if (coords.x <= 1 || coords.y <= 1 || coords.x >= map.width || coords.y >= map.height) { return; } Coords2 northCoords = DirectionHelper.NorthOf(coords); Coords2 southCoords = DirectionHelper.SouthOf(coords); Coords2 westCoords = DirectionHelper.WestOf(coords); Coords2 eastCoords = DirectionHelper.EastOf(coords); GameObject north = wallLayerTiles[northCoords.x, northCoords.y]; GameObject south = wallLayerTiles[southCoords.x, southCoords.y]; GameObject west = wallLayerTiles[westCoords.x, westCoords.y]; GameObject east = wallLayerTiles[eastCoords.x, eastCoords.y]; if (north != null && south != null) { if (west != null || east != null) { return; } wallLayerTiles[coords.x, coords.y] = RandomizeTile(horizontalDoorPrefabs); } else if (west != null && east != null) { if (north != null || south != null) { return; } wallLayerTiles[coords.x, coords.y] = RandomizeTile(verticalDoorPrefabs); } }
public GameObject GetWallTileEastOf(Coords2 coords) { return(GetTile(DirectionHelper.EastOf(coords), wallTileLayer)); }