示例#1
0
        static void Main(string[] args)
        {
            //**********test 1**********
            Console.WriteLine("**********test 1**********");
            float            percent        = new float[] { 0.5, 0.1, 0.4 }; //floor, mountain, brush
            NewCaveGenerator caveGenerator1 = new NewCaveGenerator(percent, 10, 1);

            caveGenerator1.RandomizeMap();
            for (int i = 0; i < 10; ++i)
            {
                print(caveGenerator1.GetMap());
                Console.ReadKey();
                caveGenerator1.SmoothMap();
            }

            //**********test 2**********
            Console.WriteLine("**********test 2**********");
            float            percent        = new float[] { 0.5, 0.1, 0.2, 0.2 }; //floor, mountain, brush,sea
            NewCaveGenerator caveGenerator2 = new NewCaveGenerator(percent, 10, 1);

            caveGenerator2.RandomizeMap();
            for (int i = 0; i < 10; ++i)
            {
                print(caveGenerator2.GetMap());
                Console.ReadKey();
                caveGenerator2.SmoothMap();
            }
        }
示例#2
0
    //Do the simulation in a coroutine so we can pause and see what's going on
    private IEnumerator SimulateCavePattern()
    {
        for (int i = 0; i < simulationSteps; i++)
        {
            yield return(new WaitForSeconds(0));

            //Calculate the new values
            caveGenerator.SmoothMap();

            //Generate texture and display it on the plane
            GenerateAndDisplayTexture(caveGenerator.GetMap());
        }
        Debug.Log("Simulation completed!");
    }
示例#3
0
    public void initMap()
    {
        Random.InitState(100);

        float randomFillPercentFloor = 1 - (randomFillPercentWall + randomFillPercentBush);

        randomFillPercent = new float[] { randomFillPercentFloor, randomFillPercentWall, randomFillPercentBush };

        caveGenerator = new NewCaveGenerator(randomFillPercent, gridSize, 1);
        caveGenerator.RandomizeMap();

        //For testing that init is working
        GenerateAndDisplayTexture(caveGenerator.GetMap());

        //Start the simulation
        StartCoroutine(SimulateCavePattern());
    }