Exemple #1
0
        public void GenerateMap()
        {
            var mapSize = Constants.ChunkSize * _chunksToRender;

            map = new Cell[mapSize, mapSize];

            var noise = new FastNoiseLite(Guid.NewGuid().GetHashCode());

            noise.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
            noise.SetFrequency(0.01f);
            noise.SetFractalType(FastNoiseLite.FractalType.FBm);

            var height = noise.GetNoiseMap(mapSize);

            for (var x = 0; x < mapSize; x++)
            {
                for (var z = 0; z < mapSize; z++)
                {
                    //var cellHeight = height[x, z];
                    var cellHeight = -1;
                    var terrrain   = _mapManager.TerrainDefinition.GetTerrainTypeForHeight(cellHeight);
                    map[x, z] = new Cell(x, z, terrrain.Type == TerrainType.Water ? -0.25f : 0, terrrain);
                }
            }
            _mapManager.Create(map);
        }