void OnMouseDown() { // Iterate through each of the adjacent tiles // Add this tile to a district if a neighbor is in the selected district if (district == null) { foreach (TileManager neighbor in grid.GetNeighbors(this)) { if (neighbor != null) { if (neighbor.district != null) { if (neighbor.district.selected && neighbor.district.tiles.Count < grid.districtSize) { neighbor.district.AddTile(this); } } } } // If none of the adjacent tiles were in a selected district, create a new district and select it if (district == null) { district = Instantiate(districtPrefab).GetComponent <DistrictManager> (); district.grid = grid; district.transform.position = transform.position; district.Select(); district.AddTile(this); } } else { // Select the district that the tile is in when it is clicked on if (!district.selected) { district.Select(); } } }