Exemplo n.º 1
0
        private void GenerateHeightmap()
        {
            int index = 0;

            foreach (var Tile in ListTerrainObjects)
            {
                if (index >= terrains.Length - 1)
                {
                    Debug.Log("GeneratingTerrainPhase.RepareTerrains : " + index);
                    phase = GeneratingTerrainPhase.RepareTerrains;
                }
                var terrainCount = new Vector2Int(prefs.terrainCount.x, prefs.terrainCount.y);

                int x = index % terrainCount.x;
                int y = index / terrainCount.x;

                float prog = ((index) * 100 / (terrains.GetLength(0) * terrains.GetLength(1))) / 100f;

                floatReader.GenerateHeightMap(Terrainscontainer, terrains[x, y]);
                index++;
                if (floatReader.generateComplete)
                {
                    progress = 0;
                    floatReader.generateComplete = false;
                }

                if (OnProgression != null)
                {
                    OnProgression("Generating Heightmap", (float)prog);
                }
            }
        }
        private void GenerateHeightmap(int index)
        {
            if (index >= terrains.Length)
            {
                phase = GeneratingTerrainPhase.RepareTerrains;
                return;
            }

            int x = index % terrainCount.x;
            int y = index / terrainCount.x;

            Prefs prefs = new Prefs(detailResolution, resolutionPerPatch, baseMapResolution, heightmapResolution, terrainCount);

            floatReader.GenerateHeightMap(prefs, terrains[x, y]);

            if (floatReader.generateComplete)
            {
                CurrentTerrainIndex++;

                floatReader.generateComplete = false;
            }
        }