// PLACE WATER public void PlaceWater(Vector3Int tileLocation) { // Set the target tile to be a water tile. tilemap.SetTile(tileLocation, groundTileFromName["Water"]); // Update groundTiles dictionary. groundTiles[tileLocation].ThisTile = groundTileFromName["Water"]; groundTiles[tileLocation].DistanceToWater = 0; // Get the neighbors. List <Vector3Int> neighbors = HexMath.OddrRange(tileLocation, 5); foreach (Vector3Int nPosition in neighbors) { // Look for the tile in the groundTiles dictionary. if (groundTiles.ContainsKey(nPosition)) { // Take a look at the neighbor. Look at its NearbyWaterTiles dictionary and DistanceToWater. // We want to add this new water into the dictionary and, if DistanceToWater just shrank, update // the neighbor to the appropriate tile type. int dTW = HexMath.OddrDistance(tileLocation, nPosition); if (dTW == 0) { // The tile has 0 distance to water, as in, it's looking at itself, so skip this one. continue; } else if (groundTiles[nPosition].NearbyWaterTiles.ContainsKey(dTW)) { // This value for dTW exists in the dictionary. Merely add this new water tile to the list. groundTiles[nPosition].NearbyWaterTiles[dTW].Add(tileLocation); } else { // This value for dTW did not exist in the dictionary. Create a new key value pair. groundTiles[nPosition].NearbyWaterTiles.Add(dTW, new List <Vector3Int> { tileLocation }); } // Did the neighbor get closer to water? if (dTW < groundTiles[nPosition].DistanceToWater) { // dTW changed, so we can update groundTiles dictionary. groundTiles[nPosition].DistanceToWater = dTW; // Which tile should it be, according to its distanceToWater? Tile nTile = GetTileByWaterDistance(dTW, marshDistance, soilDistance); // Start a cooroutine to change the tile. StartCoroutine(DelayedGroundTileChange(nPosition)); } } } // Last but not least, clear any plant on that tile? plantTileManager.ClearPlants(tileLocation); }
/* Clear Plants: * - Clear the tile under the cursor of plants, if any. */ public void ClearPlants(Vector3Int tilePosition) { plantTileManager.ClearPlants(tilePosition); }