Esempio n. 1
0
 // Start is called before the first frame update
 void Start()
 {
     rand    = new System.Random();
     cells   = new CellularSimulation <int>(width, height);
     meshGen = GetComponent <MeshGenerator>();
     cells.UpdateInPlace(cell => rand.Next(0, 100) <= percentFilled ? 1 : 0);
     meshGen.GenerateMesh(cells.Values(), 1);
     StartCoroutine(RunLoop());
 }
Esempio n. 2
0
    void GenerateCave()
    {
        if (!useCustomSeed)
        {
            randomSeed = Time.time.ToString();
        }

        rand  = new System.Random(randomSeed.GetHashCode());
        cells = new CellularSimulation <int>(width, height);

        cells.UpdateInPlace(InitialValue);
        for (int i = 0; i < smoothCount; i++)
        {
            cells.Update(Smooth);
        }

        MeshGenerator meshGen = GetComponent <MeshGenerator>();

        meshGen.GenerateMesh(cells.Values(), 1);
    }