protected void InitData(int startX,int startY,int mapX,int mapY,int xStepSize,int yStepSize)
        {
            LibNoise.ModuleBase noiseModual = Generator.LibnoiseModualGen.PrettyWorldGenerator();
            // Generator.LibnoiseModualGen.GetRTSGenerator(500)

            // start threaded job
            noiseJob = new LibNoiseJob(startX, startY, xStepSize, yStepSize, mapX, mapY, multyplyNoiseScale, multyplyNoiseHeight, noiseModual);
            GeneratorDataJob = new ThreadedJobHandeler();
            GeneratorDataJob.Init(noiseJob);
        }
        protected void InitData(int startX, int startY, int mapX, int mapY, int xStepSize, int yStepSize)
        {
            LibNoise.ModuleBase noiseModual = Generator.LibnoiseModualGen.PrettyWorldGenerator();
            // Generator.LibnoiseModualGen.GetRTSGenerator(500)

            // start threaded job
            noiseJob         = new LibNoiseJob(startX, startY, xStepSize, yStepSize, mapX, mapY, multyplyNoiseScale, multyplyNoiseHeight, noiseModual);
            GeneratorDataJob = new ThreadedJobHandeler();
            GeneratorDataJob.Init(noiseJob);
        }
Example #3
0
    IEnumerator UpdateParts(int terainStartX, int terainStartY)
    {
        //List<NewPart> newParts = new List<NewPart>();
        NewPart[] newPartsAr = new NewPart[((drawDist + drawDist + 1) * (drawDist + drawDist + 1))];
        int       num        = 0;
        // colect posible new tile positions
        Vector3 targetPos = target.position;

        for (int x = -drawDist; x < (drawDist + 1); x++)
        {
            for (int z = -drawDist; z < (drawDist + 1); z++)
            {
                float dist = Vector2.Distance(new Vector2(terainStartX + ((x * terainSize) - (terainSize * 0.5f)), terainStartY + ((z * terainSize) - (terainSize * 0.5f))), new Vector2(targetPos.x, targetPos.z));
                newPartsAr[num] = new NewPart(terainStartX + (x * (terainSize)), terainStartY + (z * (terainSize)), dist);
                num++;
            }
        }

        // start threaded sort job to sort possible new tiles by distance
        SortTerainGenByDistJob sortJob        = new SortTerainGenByDistJob(newPartsAr);
        ThreadedJobHandeler    sortJobHandler = new ThreadedJobHandeler();

        sortJobHandler.Init(sortJob);
        while (!sortJobHandler.JobDone)
        {
            sortJobHandler.Tick();
            yield return(null);
        }

        int currentPartsGenerated = 0;

        // generate max 2 new parts
        for (int i = 0; i < newPartsAr.Length; i++)
        {
            // generate parts
            if (GenPart(newPartsAr[i].xPart, newPartsAr[i].yPart))
            {
                currentPartsGenerated++;
            }
            ;

            if (currentPartsGenerated > 2)
            {
                break;
            }
        }
        yield return(null);

        UpdateTerain();
    }
    IEnumerator UpdateParts(int terainStartX, int terainStartY)
    {
        //List<NewPart> newParts = new List<NewPart>();
        NewPart[] newPartsAr = new NewPart[((drawDist + drawDist + 1) * (drawDist + drawDist + 1))];
        int num = 0;
        // colect posible new tile positions
        Vector3 targetPos = target.position;
        for (int x = -drawDist; x < (drawDist + 1); x++)
        {
            for (int z = -drawDist; z < (drawDist + 1); z++)
            {
                float dist = Vector2.Distance(new Vector2(terainStartX + ((x * terainSize) - (terainSize * 0.5f)), terainStartY + ((z * terainSize) - (terainSize * 0.5f))), new Vector2(targetPos.x, targetPos.z));
                newPartsAr[num] = new NewPart(terainStartX + (x * (terainSize)), terainStartY + (z * (terainSize)), dist);
                num++;
            }
        }

        // start threaded sort job to sort possible new tiles by distance
        SortTerainGenByDistJob sortJob = new SortTerainGenByDistJob(newPartsAr);
        ThreadedJobHandeler sortJobHandler = new ThreadedJobHandeler();
        sortJobHandler.Init(sortJob);
        while (!sortJobHandler.JobDone)
        {
            sortJobHandler.Tick();
            yield return null;
        }

        int currentPartsGenerated = 0;

        // generate max 2 new parts
        for (int i = 0; i < newPartsAr.Length; i++)
        {
            // generate parts
            if (GenPart(newPartsAr[i].xPart, newPartsAr[i].yPart))
            {
                currentPartsGenerated++;
            };

            if (currentPartsGenerated > 2)
            {
                break;
            }
        }
        yield return null;
        UpdateTerain();
    }