public IEnumerator PerlinNoise2DTerrainAnimation(int nOctaves, int perlinSeed, float fBias) { if (_map == null) { yield break; } int maxOctavesCount = 0; int worldWidth = _map.GetMapSize().x; while (worldWidth != 0) { worldWidth /= 2; maxOctavesCount++; } if (nOctaves > maxOctavesCount) { nOctaves = maxOctavesCount; } PerlinNoise pn = new PerlinNoise(perlinSeed); int nFrames = 100; float[,,] perlinArray = new float[_map.GetMapSize().x, _map.GetMapSize().y, nFrames]; pn.Get3DPerlinNoise(_map.GetMapSize().x, _map.GetMapSize().y, nFrames, nOctaves, fBias, ref perlinArray); for (int i = 0; i < nFrames; i++) { for (int x = 0; x < _map.GetMapSize().x; x++) { for (int y = 0; y < _map.GetMapSize().y; y++) { float height = perlinArray[x, y, i]; GameObject cell = _map.GetCellAt(new Vector2Int(x, y)).GetGameObject(); Color heightColor = new Color(height, height, height, 1); cell.GetComponent <SpriteRenderer>().color = heightColor; } } yield return(null); } }