private void DrawTiles() { Dictionary <string, Tile> loadedTiles; foreach (KeyValuePair <string, List <Vector3Int> > entry in tiles) { if (paletteTypes[entry.Key] == PaletteType.Semisolid) { loadedTiles = loadedTilesSemisolid; } else if (paletteTypes[entry.Key] == PaletteType.Danger) { loadedTiles = loadedTilesOutline; } else { loadedTiles = loadedTilesFull; } tilemaps[entry.Key].ClearAllTiles(); foreach (Vector3Int location in entry.Value) { tilemaps[entry.Key].SetTile(location, loadedTiles[TilePicker.GetTile(tiles[entry.Key], totalBounds, tileVariations, tileUpdateRadiuses, location, entry.Key, tileNames)]); } } }
private void UpdateSurroundingTiles(Vector3Int location, string id) { Dictionary <string, Tile> loadedTiles; if (paletteTypes[id] == PaletteType.Semisolid) { loadedTiles = loadedTilesSemisolid; } else if (paletteTypes[id] == PaletteType.Danger) { loadedTiles = loadedTilesOutline; } else { loadedTiles = loadedTilesFull; } int updateRadius = Mathf.FloorToInt(tileUpdateRadiuses[id]); for (int x = -updateRadius; x <= updateRadius; x++) { for (int y = -updateRadius; y <= updateRadius; y++) { if (tilemaps[id].GetTile <Tile>(location + new Vector3Int(x, y, 0)) != null && !(x == 0 && y == 0)) { tilemaps[id].SetTile(location + new Vector3Int(x, y, 0), loadedTiles[TilePicker.GetTile(tiles[id], totalBounds, tileVariations, tileUpdateRadiuses, location + new Vector3Int(x, y, 0), id, tileNames)]); } } } }
private void UpdateAllTiles() { Dictionary <string, Tile> loadedTiles; foreach (KeyValuePair <string, Tilemap> entry in tilemaps) { if (paletteTypes[entry.Key] == PaletteType.Semisolid) { loadedTiles = loadedTilesSemisolid; } else if (paletteTypes[entry.Key] == PaletteType.Danger) { loadedTiles = loadedTilesOutline; } else { loadedTiles = loadedTilesFull; } for (int x = totalBounds.xMin; x <= totalBounds.xMax; x++) { for (int y = totalBounds.yMin; y <= totalBounds.yMax; y++) { if (tilemaps[entry.Key].GetTile <Tile>(new Vector3Int(x, y, 0)) != null && !(x == 0 && y == 0)) { tilemaps[entry.Key].SetTile(new Vector3Int(x, y, 0), loadedTiles[TilePicker.GetTile(tiles[entry.Key], totalBounds, tileVariations, tileUpdateRadiuses, new Vector3Int(x, y, 0), entry.Key, tileNames)]); } } } } }
private void PlaceTile(string id, Vector3Int location) { if (tiles[id].Contains(location)) { return; } Dictionary <string, Tile> loadedTiles; if (paletteTypes[id] == PaletteType.Semisolid) { loadedTiles = loadedTilesSemisolid; } if (paletteTypes[id] == PaletteType.Danger) { loadedTiles = loadedTilesOutline; } else { loadedTiles = loadedTilesFull; } tiles[id].Add(location); tilemaps[id].SetTile(location, loadedTiles[TilePicker.GetTile(tiles[id], totalBounds, tileVariations, tileUpdateRadiuses, location, id, tileNames)]); playCam.GetComponent <PlayCameraController>().UpdateBounds(CalculateBounds()); UpdateSurroundingTiles(location, id); }