Пример #1
0
    void Start()
    {
        //To get the same random numbers each time we run the script
        Random.InitState(100);
        caveGenerator = new CaveGenerator(randomFillPercent, gridSize);
        caveGenerator.RandomizeMap();

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

        //Start the simulation
        StartCoroutine(SimulateCavePattern());
    }
    //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(pauseTime));

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

            //Generate texture and display it on the plane
            GenerateAndDisplayTexture(caveGenerator.GetMap());
        }
        Debug.Log("Simulation completed!");
    }
Пример #3
0
        static void Main(string[] args)
        {
            CaveGenerator caveGenerator = new CaveGenerator(0.3f, 10);

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

            Console.WriteLine("End CaveGenerator Test");
        }
Пример #4
0
    private void Update()
    {
        if (Player.transform.position.x > gridSize - 1 && Player.transform.position.y > gridSize - 1)
        {
            float addgrid = (float)gridSize * ((float)growMap / 100);
            gridSize += (int)addgrid;
            //Debug.Log("addgrid size is:   " + addgrid);
            // Debug.Log("grid size is:   "+gridSize);
            caveGenerator = new CaveGenerator(randomFillPercent, gridSize);
            //Calculate the new values
            caveGenerator.RandomizeMap();
            caveGenerator.SmoothMap(gridSize);

            //Generate texture and display it on the plane
            GenerateAndDisplayTexture(caveGenerator.GetMap());

            Player.transform.position = new Vector3(2.16f, 1.47f, 0);
        }
    }