public static void PlaceFloorTile(Vector2Int _buildPoint) { Vector3Int t = new Vector3Int(_buildPoint.x, _buildPoint.y, 0); if (!TileManager.GetTileDictionaryFloor().ContainsKey(t)) { TileHolder tileHolder = TileManager.GetTileHolder(TileType.Floor); float randomFreq = Random.Range(1, tileHolder.Tiles.OrderByDescending(t => t.PickChance).First().PickChance); List <CustomTile> tilesWithinRange = new List <CustomTile>(); tilesWithinRange = tileHolder.Tiles.Where(t => t.PickChance >= randomFreq).ToList(); int tempTileIndex; tempTileIndex = Random.Range(0, tilesWithinRange.Count); TileManager.PlaceTile(t, tempTileIndex, null, DungeonUtility.GetTilemap(), tilesWithinRange[tempTileIndex], DictionaryType.Floor); m_floorPositions.Add(t); Tile tileT = DungeonUtility.GetTilemap().GetTile <Tile>(t); if (tilesWithinRange[tempTileIndex].SpriteVariations.Length > 0) { Sprite sT = tilesWithinRange[tempTileIndex].SpriteVariations[Random.Range(0, tilesWithinRange[tempTileIndex].SpriteVariations.Length)]; if (sT != null) { tileT.sprite = sT; } } } }
public static void PlaceWalls() { BoundsInt Bounds = DungeonUtility.GetTilemap().cellBounds; TileBase[] allTiles = DungeonUtility.GetTilemap().GetTilesBlock(Bounds); List <CustomTile> tilesWithinRange = new List <CustomTile>(); TileHolder tileHolder = TileManager.GetTileHolder(TileType.Wall); for (int x = 0; x < Bounds.size.x; x++) { for (int y = 0; y < Bounds.size.y; y++) { float randomFreq = Random.Range(1, tileHolder.Tiles.OrderByDescending(t => t.PickChance).First().PickChance); tilesWithinRange = tileHolder.Tiles.Where(t => t.PickChance >= randomFreq).ToList(); TileBase tile = allTiles[x + y * Bounds.size.x]; int tempTileIndex; tempTileIndex = Random.Range(0, tilesWithinRange.Count); Vector3Int pos = new Vector3Int(x, y, 0); if (tile == null) { TileManager.PlaceTile(pos, tempTileIndex, null, m_walls, tilesWithinRange[tempTileIndex], DictionaryType.Walls); Tile tileT = m_walls.GetTile <Tile>(pos); if (tilesWithinRange[tempTileIndex].SpriteVariations.Length > 0) { Sprite sT = tilesWithinRange[tempTileIndex].SpriteVariations[Random.Range(0, tilesWithinRange[tempTileIndex].SpriteVariations.Length)]; if (sT != null) { tileT.sprite = sT; } } } } } }
static void BuildPathTile(Vector3Int _pos) { TileHolder tileHolder = TileManager.GetTileHolder(TileType.Path); float randomFreq = Random.Range(1, tileHolder.Tiles.OrderByDescending(t => t.PickChance).First().PickChance); List <CustomTile> tilesWithinRange = new List <CustomTile>(); tilesWithinRange = tileHolder.Tiles.Where(t => t.PickChance >= randomFreq).ToList(); int tempTileIndex; tempTileIndex = Random.Range(0, tilesWithinRange.Count); TileManager.PlaceTile(_pos, tempTileIndex, WallGen.GetTilemap(), DungeonUtility.GetTilemap(), tilesWithinRange[tempTileIndex], DictionaryType.Floor); }