public void UpdateMap() { for (int y = 0; y < overlay.size.y; y += 1) { for (int x = 0; x < overlay.size.x; x += 1) { overlay.SetTile(new Vector3Int(x, y, 0), null); } } Tilemap tileset = tilesetPrefab.GetComponentInChildren <Tilemap>(); for (int y = 0; y < tileset.size.y; y += 1) { for (int x = 0; x < tileset.size.x; x += 1) { Vector3Int loc = new Vector3Int(x, y, 0); PropertiedTile tile = (PropertiedTile)tileset.GetTile(loc); TileBase overlayTile = null; switch (mode) { case PaintMode.Passability: overlayTile = tile.GetData().impassable ? tileO : tileX; break; } overlay.SetTile(loc, overlayTile); } } }
public void CheckForChanges() { Tilemap tileset = tilesetPrefab.GetComponentInChildren <Tilemap>(); for (int y = 0; y < overlay.size.y; y += 1) { for (int x = 0; x < overlay.size.x; x += 1) { Vector3Int loc = new Vector3Int(x, y, 0); PropertiedTile tile = (PropertiedTile)tileset.GetTile(loc); TileBase overlayTile = overlay.GetTile(loc); switch (mode) { case PaintMode.Passability: if (overlayTile == tileO && !tile.GetData().impassable) { tile.GetData().impassable = true; } else if (overlayTile == tileX && tile.GetData().impassable) { tile.GetData().impassable = false; } break; } } } UpdateMap(); }
public bool IsChipPassableAt(Tilemap layer, Vector2Int loc) { if (passabilityMap == null) { passabilityMap = new Dictionary <Tilemap, bool[, ]>(); } if (!passabilityMap.ContainsKey(layer)) { passabilityMap[layer] = new bool[width, height]; for (int x = 0; x < width; x += 1) { for (int y = 0; y < height; y += 1) { PropertiedTile tile = TileAt(layer, x, y); passabilityMap[layer][x, y] = tile == null || tile.GetData().passable; } } } return(passabilityMap[layer][loc.x, loc.y]); }
public bool IsChipPassableAt(Tilemap layer, Vector2Int loc) { PropertiedTile tile = TileAt(layer, loc.x, loc.y); return(tile == null || !tile.GetData().impassable); }