private MapData GenerateSpecials(MapData _mapData, int _mapChunkSize, float _heigtCurveStartValue) { ObstacleData[,] obstacleData = new ObstacleData[_mapChunkSize, _mapChunkSize]; //spawn a random amount of island at random locations in the chunk. int randomSpecialCount = Random.Range(minSpecialAmount, maxSpecialAmount); for (int i = 0; i < randomSpecialCount; i++) { Vector2 spawnPos = new Vector2(Random.Range(specialGroundClearingSize, _mapChunkSize - specialGroundClearingSize), Random.Range(specialGroundClearingSize, _mapChunkSize - specialGroundClearingSize)); //if the spawnPos we generated is not high enough, generate a new one until we have a good one while (_mapData.noiseMap[(int)spawnPos.x, (int)spawnPos.y] >= _heigtCurveStartValue) { spawnPos = new Vector2(Random.Range(specialGroundClearingSize, _mapChunkSize - specialGroundClearingSize), Random.Range(specialGroundClearingSize, _mapChunkSize - specialGroundClearingSize)); } _mapData = NoiseEditor.FlattenNoiseArea(_mapData, 0, true, EnumTypes.FigureMode.Circle, spawnPos, specialGroundClearingSize, _mapChunkSize); obstacleData[(int)spawnPos.x, (int)spawnPos.y].nodeValue = Mathf.FloorToInt((obstacleTypes.Length - 1) * Random.Range(0, 0.99f)) + 1; } _mapData.obstacleData = obstacleData; obstacleData = null; return(_mapData); }
private void MakeLandConnection(Vector2 _ourIslandLocalCoordinates, Vector2 _ourChunkCoordinates, Vector2 _destinationChunkCoordinates, int _pathWidth, int _mapChunkSize) { int destinationClearSize = 10; Vector2 localDestination = new Vector2(Random.Range(destinationClearSize, _mapChunkSize - destinationClearSize), Random.Range(destinationClearSize, _mapChunkSize - destinationClearSize)); MapData destinationMapdata = MapGenerator.mapDataContainer[_destinationChunkCoordinates]; destinationMapdata = NoiseEditor.FlattenNoiseArea(destinationMapdata, 0, true, EnumTypes.FigureMode.Circle, localDestination, destinationClearSize, _mapChunkSize); MapGenerator.mapDataContainer[_destinationChunkCoordinates] = destinationMapdata; Paths.CreatePathChunksOverflow(_ourChunkCoordinates, _destinationChunkCoordinates, _ourIslandLocalCoordinates, localDestination, 0, _pathWidth, pathSmoothness, false, _mapChunkSize); }