internal void AlterBiome(BiomeCell biomeCell) { if (biomeCell.type == selectedBiome.type) { return; } biomeCell.SetBiome(selectedBiome); CreateTrianglesForBiome(biomeCell); }
void ChooseBiome(BiomeCell cell) { var neighborCoordinates = cell.coordinates.AllNeighbors(); var neighborTypes = biomeCells.Where(biomeCell => neighborCoordinates.Contains(biomeCell.coordinates) && biomeCell.type.HasValue) .Select(neighborCell => neighborCell.type.Value) .ToList(); var possibilities = new Dictionary <Biome, float>(); biomes.Values.ForEach(biome => possibilities.Add(biome, biome.GetWeight(neighborTypes))); var sum = 0.0; var total = possibilities.Values.Sum(); var rand = UnityEngine.Random.value * total; var chosenBiome = possibilities.First(entry => { sum += entry.Value; return(rand < sum); }).Key; cell.SetBiome(chosenBiome); }