コード例 #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());
 }
コード例 #2
0
    IEnumerator RunLoop()
    {
        MeshGenerator meshGen = GetComponent <MeshGenerator>();

        while (true)
        {
            cells.Update(Tick);
            meshGen.GenerateMesh(cells.Values(), 1);
            yield return(new WaitForSeconds(0.5f));
        }
    }
コード例 #3
0
ファイル: CaveGenerator.cs プロジェクト: jspong/bloggo
    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);
    }