public void GenerateMap()
    {
        float[,] noiseMap = Noise.GenNoiseMap(mapWidth, mapHeight, seed, noiseScale, octaves, persistance, lacunarity);
        BorderMap();
        Color[] colorMap = new Color[mapWidth * mapHeight];

        for (int y = 0; y < mapHeight; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                if (borderStyle == BorderStyle.IsleMap)
                {
                    noiseMap[x, y] = Mathf.Clamp01(noiseMap[x, y] - borderMap[x, y]);
                }
                else if (borderStyle == BorderStyle.ClosedMap)
                {
                    noiseMap[x, y] = Mathf.Clamp01(noiseMap[x, y] + borderMap[x, y]);
                }

                float currentHeight = noiseMap[x, y];
                for (int i = 0; i < regions.Length; i++)
                {
                    if (currentHeight <= regions[i].height)
                    {
                        colorMap[y * mapWidth + x] = regions[i].color;
                        break;
                    }
                }
            }
        }

        MapDisplay display = FindObjectOfType <MapDisplay>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(noiseMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColorMap(colorMap, mapWidth, mapHeight));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MashGenerator.GenerateTerrainMesh(noiseMap, meshGeightMultiplier, meshHeightCurve), TextureGenerator.TextureFromColorMap(colorMap, mapWidth, mapHeight));
        }
        else if (drawMode == DrawMode.IsleMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(IslMapGenerator.GenerateIslMap(mapWidth, mapHeight)));
        }
        else if (drawMode == DrawMode.ClosedMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(IslMapGenerator.GenerateIslMap(mapWidth, mapHeight)));
        }

        #region Check (Проверка на входящие данные)

        if (mapWidth < 1)
        {
            mapWidth = 1;
        }
        if (mapHeight < 1)
        {
            mapHeight = 1;
        }
        if (lacunarity < 1)
        {
            lacunarity = 1;
        }
        if (octaves < 0)
        {
            octaves = 0;
        }
        if (noiseScale < 1)
        {
            noiseScale = 1;
        }
        if (seed < 0)
        {
            seed = 0;
        }

        #endregion Validate
    }
 public void BorderMap()
 {
     borderMap = IslMapGenerator.GenerateIslMap(mapHeight, mapWidth);
 }