Ejemplo n.º 1
0
    internal void AlterBiome(BiomeCell biomeCell)
    {
        if (biomeCell.type == selectedBiome.type)
        {
            return;
        }

        biomeCell.SetBiome(selectedBiome);
        CreateTrianglesForBiome(biomeCell);
    }
Ejemplo n.º 2
0
    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);
    }