示例#1
0
    IEnumerator InitialisationCoroutine()
    {
        moveSpeed = 0.15f;

        //Random.InitState(randomSeed); uncomment to seed simulation
        mf = gameObject.AddComponent <MeshFilter>();
        mr = gameObject.AddComponent <MeshRenderer>();

        sliderProgress += 0.2f;
        yield return(null);

        testCrust = new Crust(meshWidth, meshHeight, triSize, seaLevel: 1.0f);

        sliderProgress += 0.2f;
        yield return(null);

        testCrust.Mesh = MeshBuilder.BuildMesh(mf, mr, meshWidth, meshHeight, triSize);

        testCrust = TerrainGeneration.ApplyFractalToCrust(testCrust);
        Debug.Log("in apply: " + testCrust.CrustNodes[30, 222][0].Height);

        sliderProgress += 0.2f;
        yield return(null);

        testCrust = PlateGeneration.SplitCrustIntoPlates(testCrust, meshWidth, meshHeight, plateCount, voronoiRelaxationSteps);

        sliderProgress += 0.2f;
        yield return(null);

        for (int i = 0; i < testCrust.Plates.Length; i++)
        {
            while ((testCrust.Plates[i].XSpeed <0.3f && testCrust.Plates[i].XSpeed> -0.3f) && (testCrust.Plates[i].ZSpeed <0.3f && testCrust.Plates[i].ZSpeed> -0.3f))
            {
                testCrust.Plates[i].AccurateXSpeed = Random.Range(-2f, 2f);
                testCrust.Plates[i].AccurateZSpeed = Random.Range(-2f, 2f);
            }

            sliderProgress += (0.2f / testCrust.Plates.Length);
            yield return(null);
        }

        sliderBar.gameObject.SetActive(false);
    }