Inheritance: MonoBehaviour
    float[,] GenerateMapData()
    {
        float[,] noiseMap = NoiseGenerator.NoiseMap(terrainControl.mapSize, terrainControl);

        //if were using the island map
        if (terrainControl.useIsland)
        {
            terrainControl.IslandMap = IslandGenerator.GenerateIsland(terrainControl.mapSize);
        }

        for (int y = 0; y < terrainControl.mapSize; y++)
        {
            for (int x = 0; x < terrainControl.mapSize; x++)
            {
                //if were using the IslandMap the apply it
                if (terrainControl.useIsland)
                {
                    //combine both maps, and clamp value between 0-1
                    noiseMap[x, y] = Mathf.Clamp01(noiseMap[x, y] - terrainControl.IslandMap[x, y]);
                }
            }
        }

        textureControl.UpdateTextures(terrainControl.minHeight, terrainControl.maxHeight, terrainMaterial);

        return(noiseMap);
    }
Exemple #2
0
        private void generateIslandMeshes()
        {
            var islandGenerator         = new CachedIslandGenerator(new IslandGenerator(), new OBJExporter());
            var realtimeIslandGenerator = new IslandGenerator();

            Console.WriteLine("Generating island bases");
            level.Islands.ForEach(i =>
            {
                var desc          = i.Descriptor;
                desc.BaseElements = islandGenerator.GetIslandBase(i.Descriptor.seed);

                IMesh temp;
                List <IBuildingElement> navMesh;
                List <IBuildingElement> buildmesh;
                List <IBuildingElement> bordermesh;
                realtimeIslandGenerator.GetIslandParts(desc.BaseElements, desc.seed, false, out temp, out navMesh, out buildmesh, out bordermesh);

                i.SpaceAllocator.BuildAreaMeshes = buildmesh;
                desc.BuildMesh = buildmesh;
                desc.NavMesh   = navMesh;

                i.Descriptor = desc;
            });

            Console.WriteLine("Generating island meshes");
            level.Islands.ForEach(i =>
            {
                var desc     = i.Descriptor;
                var mesh     = islandGenerator.GetIslandMesh(desc.BaseElements, desc.seed);
                i.Mesh       = mesh;
                i.Descriptor = desc;
            });
        }
Exemple #3
0
    public void GenerateIsland()
    {
        float[,] noiseMap = Noise.GenerateNoiseMap(bottomWidth, bottomHeight, noiseScale, octaves, persistence, lacunarity, offset);
        MeshData newIsland = IslandGenerator.GenerateIslandMesh(noiseMap);

        GetComponent <IslandDisplay>().DrawMesh(newIsland, placeholder);
    }
    private void GenerateIsland()
    {
        //GameObject generatorObj = new GameObject();
        //IslandGenerator gen = generatorObj.AddComponent<IslandGenerator>();
        GameObject      islandGenPrefab = Resources.Load <GameObject>("Prefabs/IslandGenerator");
        GameObject      generatorObj    = (GameObject)Instantiate(islandGenPrefab);
        IslandGenerator gen             = generatorObj.GetComponent <IslandGenerator>();

        GameObject[] detailObjects = new GameObject[]
        {
            Resources.Load <GameObject>(_secondSetPath + "Pine_0"),
            Resources.Load <GameObject>(_secondSetPath + "Pine_1"),
            Resources.Load <GameObject>(_secondSetPath + "Pine_2"),
            Resources.Load <GameObject>(_secondSetPath + "Rock_Med"),
            //Resources.Load<GameObject>(_secondSetPath + "Rock_Lg"),
            Resources.Load <GameObject>(_secondSetPath + "Flower_Bud"),
            //Resources.Load<GameObject>(_secondSetPath + "Bush_Sm"),
            Resources.Load <GameObject>(_secondSetPath + "Grass"),
            Resources.Load <GameObject>(_secondSetPath + "Fern"),
            //Resources.Load<GameObject>(_secondSetPath + "Rock_Small")
        };

        gen._detailObjects = detailObjects;
        GameObject terrainObj = gen.Generate(_size, _seed, _levels);

        PrefabUtility.CreatePrefab("Assets/Resources/Custom Islands Generated/" + terrainObj.name + ".prefab", terrainObj);

        DestroyImmediate(generatorObj);
        DestroyImmediate(terrainObj);
    }
    public override void OnInspectorGUI()
    {
        IslandGenerator islandGen = (IslandGenerator)target;

        if (DrawDefaultInspector())
        {
            if (islandGen.autoUpdate)
            {
                islandGen.GenerateMap();
            }
        }

        if (GUILayout.Button("Generate"))
        {
            islandGen.GenerateMap();
        }
        if (GUILayout.Button("StartAutoGen"))
        {
            if (!islandGen.autoGenerate)
            {
                Debug.Log("hello");
                islandGen.autoGenerate = true;
                islandGen.StartAutoGeneration();
            }
        }
        if (GUILayout.Button("StopAutoGen"))
        {
            islandGen.autoGenerate = false;
            islandGen.StopAutoGeneration();
        }
    }
    void Start()
    {
        islandGen = FindObjectOfType <IslandGenerator>();

        maxViewDist = detailLevels[detailLevels.Length - 1].visibleDistanceThreshhold;

        chunkSize     = IslandGenerator.mapChunkSize - 1;
        chunksVisible = Mathf.RoundToInt(maxViewDist / chunkSize);
    }
 private void Awake()
 {
     islandUI         = GetComponent <IslandUI>();
     col              = GetComponent <BoxCollider>();
     meshObjects      = new List <GameObject>();
     generator        = GetComponent <IslandGenerator>();
     UniqueIslandData = new UniqueIslandData();
     info             = new IslandInfo();
     UniqueIslandData.Initialize();
 }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        IslandGenerator generator = (IslandGenerator)target;

        if (GUILayout.Button("Build Mesh"))
        {
            generator.createAndUpdateMesh();
        }
    }
    //private int nbCreaturesPerSpecie = 5;
    //private int nbCreatures = 30;

    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(this.gameObject);
        }
        else
        {
            Destroy(this);
        }
    }
    //To clamp the values to 0 or 1
    private void OnValidate()
    {
        if (lacunarity < 1)
        {
            lacunarity = 1;
        }
        if (octaves < 0)
        {
            octaves = 0;
        }

        islandGenMap = IslandGenerator.GenerateIslandEffect(mapChunkSize);
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        //setting values
        IslandGenerator thisGenerator = (IslandGenerator)target;

        thisGenerator.polygonCount    = EditorGUILayout.IntField("Polygon Count", thisGenerator.polygonCount);
        thisGenerator.resolution      = EditorGUILayout.IntField("Resolution", thisGenerator.resolution);
        thisGenerator.lloydIterations = EditorGUILayout.IntField("LLoyd Iterations", thisGenerator.lloydIterations);
        Rect lastRect = GUILayoutUtility.GetLastRect();
        //EditorGUI.DrawPreviewTexture(new Rect(lastRect.x, lastRect.y, 100, 100), thisGenerator.firstStep); TODO: fix the preview texture
    }
    void Start()
    {
        myRigidbody = GetComponent <Rigidbody>();
        rotation    = myRigidbody.rotation;
        OnEnabled();
        currentHealth = startingHealth;
        GameObject gen = GameObject.Find("IslandGenerator");

        if (gen)
        {
            generator = gen.GetComponent <IslandGenerator>();
        }
    }
    public void Init(OceanManager manager, Vector2Int WorldGridPosition, IslandGenerator Generator)
    {
        this.Ocean             = manager;
        this.WorldGridPosition = WorldGridPosition;
        this.Generator         = Generator;

        this.Chunks            = new List <GameObject>();
        this.CollidersToUpdate = new List <GameObject>();

        transform.position = new Vector3(WorldGridPosition.x * manager.OneGridPointToWorld, 0, WorldGridPosition.y * manager.OneGridPointToWorld);

        Generator.SetupIslandForGeneration(this);
        Generate(Generator.GetSeed());
    }
Exemple #14
0
        public void TestIslandGenerator()
        {
            initializeTW();

            var generator = new IslandGenerator();

            int seed        = 1;
            var startShapes = generator.GetIslandBase(seed);
            var islandMesh  = generator.GetIslandMesh(startShapes, seed);

            deferredRenderer.CreateMeshElement(islandMesh);

            engine.AddSimulator(new WorldRenderingSimulator());
        }
Exemple #15
0
    void Start()
    {
        // get board data
        TileData.hash  = new Hashtable();
        TileData.tiles = new TopTile[tilesX, tilesY];
        TileData.x     = tilesX;
        TileData.y     = tilesY;

        Board board = new Board(tilesX, tilesY);

        board.generate(tileSize, maxHeight, smoothness);

        // index islands
        IslandGenerator islandGenerator = new IslandGenerator(tilesX, tilesY);

        islandGenerator.generate();
    }
    public override void OnInspectorGUI()
    {
        IslandGenerator islandGen = (IslandGenerator)target;

        if (DrawDefaultInspector())
        {
            if (islandGen.autoUpdate)
            {
                islandGen.DrawMapInEditor();
            }
        }

        if (GUILayout.Button("Generate"))
        {
            islandGen.DrawMapInEditor();
        }
    }
        public void TestIslandBuildArea()
        {
            const int seed        = 1;
            var       generator   = new IslandGenerator();
            var       startShapes = generator.GetIslandBase(seed);
            IMesh     islandMesh;
            List <IBuildingElement> navMesh;
            List <IBuildingElement> buildMesh;
            List <IBuildingElement> borderMesh;

            generator.GetIslandParts(startShapes, seed, false, out islandMesh, out navMesh, out buildMesh, out borderMesh);

            //buildMesh = buildMesh.Where(e => ((Face)e).GetBoundingBox().Maximum.Y < 1f).ToList();

            var spaceManager = new IslandSpaceAllocator {
                BuildAreaMeshes = buildMesh
            };

            var nbBoxes     = 10;
            var rnd         = new Random(0);
            var placedBoxes = generateBuildPlots(rnd, spaceManager, nbBoxes, 1f, 10f);

            DX11Game game        = TW.Graphics;
            var      infoDisplay = new Textarea();

            infoDisplay.Size    = new Vector2(500, 50);
            game.GameLoopEvent += delegate
            {
                if (game.Keyboard.IsKeyPressed(Key.F))
                {
                    spaceManager.ClearBuildingSpotReservations();
                    placedBoxes = generateBuildPlots(rnd, spaceManager, nbBoxes, 1f, 10f);
                }

                foreach (var el in buildMesh)
                {
                    TW.Graphics.LineManager3D.AddBox(el.GetBoundingBox(), new Color4(1, 1, 1));
                }
                foreach (var box in placedBoxes)
                {
                    TW.Graphics.LineManager3D.AddBox(box, new Color4(1, 0, 0));
                }
                infoDisplay.Text = "Press F to regenerate";
            };
        }
    public override void OnInspectorGUI()
    {
        IslandGenerator islandGen = target as IslandGenerator;

        if (DrawDefaultInspector())
        {
            if (islandGen.autoUpdate)
            {
                islandGen.GenerateIsland();
            }
        }

        GUILayout.Space(10);
        if (GUILayout.Button("Generate"))
        {
            islandGen.GenerateIsland();
        }
    }
Exemple #19
0
    private void MakeNewIsland(IslandGenerator gen, int islandSeed, float[][] moistNoise, float[][] tempNoise)
    {
        System.Random islandPRNG = new System.Random(islandSeed);

        IslandSize size              = DetermineIslandSize(islandPRNG.Next());
        int        islandSize        = (int)size;
        int        x                 = islandPRNG.Next(islandSize, MaxWorldSize - islandSize);
        int        z                 = islandPRNG.Next(islandSize, MaxWorldSize - islandSize);
        Vector3    position          = new Vector3(x, 0f, z);
        int        numOfHeightLevels = islandPRNG.Next(MinNumberOfHeightLevels) + MinNumberOfHeightLevels;  // dont want island with < min height levels

        // should check to make sure islands can't overlap each other

        // copy out the relevant climate noise
        float[][] islandSpecificMoistureData = new float[islandSize][];
        float[][] islandSpecificTempData     = new float[islandSize][];
        //Debug.LogFormat("specific: {0}x{1}", islandSpecificBiomeData.Length, islandSpecificBiomeData[0].Length);
        //Debug.LogFormat("base: {0}x{1}", biomeNoise.Length, biomeNoise[0].Length);

        for (int i = 0; i < islandSize; ++i)
        {
            islandSpecificMoistureData[i] = new float[islandSize];
            islandSpecificTempData[i]     = new float[islandSize];

            for (int j = 0; j < islandSize; ++j)
            {
                //Debug.LogFormat("specific -> i: {0}, j:{1}, base -> i:{2} j:{3}",i, j, i + x, j + z);
                islandSpecificMoistureData[i][j] = moistNoise[i + x][j + z];
                islandSpecificTempData[i][j]     = tempNoise[i + x][j + z];
            }
        }


        Debug.LogFormat("new island at {0} of size {1} with {2} levels ({3})", position, size.ToString(), numOfHeightLevels, islandSeed);

        // TODO
        // create an island data class that will be returned from this function
        // should hold things like:
        // tile array, native species of plants/vegetables/etc, general climate, size, soil classification, ...

        IslandData data = gen.Generate(size, islandSeed, position, islandSpecificMoistureData, islandSpecificTempData, numOfHeightLevels);

        _islands.Add(data);
    }
Exemple #20
0
        public void TestIslandParts()
        {
            var seed = 1;

            #region init
            hideAxes = true;
            initializeTW();
            throw new NotImplementedException();
            TWRenderWrapper renderer = null;// = new TWRenderWrapper(deferredRenderer, game);
            renderer.DrawFaceUnitAxes = false;
            rnd.Reset(seed);
            #endregion init

            var   generator   = new IslandGenerator();
            var   startShapes = generator.GetIslandBase(seed);
            IMesh islandMesh;
            List <IBuildingElement> navMesh;
            List <IBuildingElement> buildMesh;
            List <IBuildingElement> borderMesh;
            generator.GetIslandParts(startShapes, seed, true, out islandMesh, out navMesh, out buildMesh, out borderMesh);

            var allFaces = navMesh.Select(element => ((Face)element).ExtraTransform(Matrix.Translation(0, 0, 0.25f), "nav")).ToList();
            allFaces.AddRange(buildMesh.Select(element => ((Face)element).ExtraTransform(Matrix.Translation(0, 0, 4), "build")));
            allFaces.AddRange(borderMesh.Select(element => ((Face)element).ExtraTransform(Matrix.Translation(0, 0, 8), "border")));

            var builder = new Builder(renderer);
            builder.Build(allFaces, new RuleBase(), seed);
            deferredRenderer.CreateMeshElement(islandMesh);

            game.GameLoopEvent += delegate
            {
                if (game.Keyboard.IsKeyPressed(Key.L))
                {
                    extraLight.LightPosition = camera.GetCameraPosition();
                }
                renderer.Update();
                update();
                cameraLight.LightPosition = new Vector3(10, 15, 5);
            };

            game.Run();
        }
    public override void OnInspectorGUI()
    {
        IslandGenerator islandGen = target as IslandGenerator;

        if (DrawDefaultInspector())
        {
            if (islandGen.autoUpdate)
            {
                LoggerTool.Post("Generate island from Editor");
                islandGen.GenerateIsland(false);
            }
        }

        GUILayout.Space(10);
        if (GUILayout.Button("Generate"))
        {
            LoggerTool.Post("Generate island from Editor");
            islandGen.GenerateIsland(false);
        }
    }
Exemple #22
0
    private void GenerateWorld(int worldSeed)
    {
        GameObject      islGen    = (GameObject)Instantiate(_islandGenPrefab, Vector3.zero, Quaternion.identity);
        IslandGenerator generator = islGen.GetComponent <IslandGenerator>();

        System.Random worldPRNG = new System.Random(worldSeed);

        // biome/climate regions
        PerlinGenerator moistureNoiseGen = new PerlinGenerator();
        PerlinGenerator tempNoiseGen     = new PerlinGenerator();

        int octaves = 9;         // higher octaves (10+) create large biomes

        float[][] moistureNoise    = moistureNoiseGen.Generate(worldSeed, octaves, MaxWorldSize);
        float[][] temperatureNoise = tempNoiseGen.Generate(worldSeed, octaves, MaxWorldSize);

        for (int i = 0; i < NumberOfIslands; ++i)
        {
            MakeNewIsland(generator, worldPRNG.Next(), moistureNoise, temperatureNoise);
        }
    }
Exemple #23
0
    private void OnValidate()
    {
        if (terrainData != null)
        {
            terrainData.OnValuesUpdated -= OnValuesUpdated;
            terrainData.OnValuesUpdated += OnValuesUpdated;
        }

        if (noiseData != null)
        {
            noiseData.OnValuesUpdated -= OnValuesUpdated;
            noiseData.OnValuesUpdated += OnValuesUpdated;
        }

        if (erosionData != null)
        {
            erosionData.OnValuesUpdated -= OnValuesUpdated;
            erosionData.OnValuesUpdated += OnValuesUpdated;
        }

        if (textureData != null)
        {
            textureData.OnValuesUpdated -= OnTextureValuesUpdated;
            textureData.OnValuesUpdated += OnTextureValuesUpdated;
        }

        if (noiseData.lacunarity < 1)
        {
            noiseData.lacunarity = 1;
        }
        if (noiseData.octaves < 0)
        {
            noiseData.octaves = 0;
        }
        if (fallofMap == null)
        {
            fallofMap = IslandGenerator.GenerateFallofMap(mapChunkSize);
        }
    }
Exemple #24
0
    private List <IslandObject> GenerateLevelOne()
    {
        List <int>      islands         = new List <int>();
        IslandGenerator island_gen      = new IslandGenerator();
        const int       level           = 1;
        const int       end_island      = 7;
        int             shop_island     = rnd.Next(1, end_island); // Random number: 1<=shop_island<end_island
        int             distress_island = rnd.Next(1, end_island); // Random number: 1<=shop_island<end_island

        while (shop_island == distress_island)                     // Ensure that we aren't trying to add the shop and distress islands to the same island number
        {
            distress_island = rnd.Next(1, end_island);
        }
        for (int i = 0; i < end_island + 1; i++)
        {
            if (i == 0)
            {
                islands.Add(0); // Start Island
            }
            else if (i == shop_island)
            {
                islands.Add(1); // Merchant Island
            }
            else if (i == distress_island)
            {
                islands.Add(3); // Distress Island
            }
            else if (i == end_island)
            {
                islands.Add(4); // End Island
            }
            else
            {
                islands.Add(2);// Enemy Island
            }
        }
        return(island_gen.GenerateIslands(islands, level));
    }
    public void DrawMapInEditor()
    {
        MapData mapData = GenerateMapData(Vector2.zero);

        DisplayMap display = FindObjectOfType <DisplayMap>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(mapData.heightMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColourMap(mapData.colorMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(mapData.heightMap, meshHeightMultiplier, meshHeightCurve, editorPreviewLOD, useFlatShading), TextureGenerator.TextureFromColourMap(mapData.colorMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(IslandGenerator.GenerateIslandEffect(mapChunkSize)));
        }
    }
Exemple #26
0
        public void CoordtoCenterTest_Send0_Getnegative1()
        {
            var sut = new IslandGenerator(1);

            Assert.AreEqual(-1, sut.GetStdCoord(0.0));
        }
Exemple #27
0
        public void CoordtoCenterTest_Send10_Get1()
        {
            var sut = new IslandGenerator(1);

            Assert.AreEqual(1, sut.GetStdCoord(10.0));
        }
Exemple #28
0
        public void CoordtoCenterTest_Send5_Get0()
        {
            var sut = new IslandGenerator(1);

            Assert.AreEqual(0, sut.GetStdCoord(5.0));
        }
Exemple #29
0
 void Awake()
 {
     fallofMap = IslandGenerator.GenerateFallofMap(mapChunkSize);
 }
    /// <summary>
    /// This overrides the default InspectorGUI
    /// </summary>
    public override void OnInspectorGUI()
    {
        //Here we check once more if the Terrain has a TerrainData attached to it.
        //OnEnable() doesn't trigger if you just drag&drop the data to the inspector and
        //the Island Generator GUI doesn't show up. OnInspectorGUI() triggers more often,
        //so here we'll start checking whether or not Terrain has TerrainData asset in it.
        if (terraini == null && t != null && !isTerrain)
        {
            terraini = t.terrainData as Object;

            //Terraindata detected, we can draw the GUI.
            if (terraini != null)
            {
                terrainReso = t.terrainData.heightmapResolution;
                isTerrain   = true;
            }
        }

        //If there is no Terrain or TerrainData, this draws an error message in the Inspector
        //rather than the actual Generator GUI
        if (!isTerrain)
        {
            EditorGUILayout.BeginVertical("box");
            EditorGUILayout.LabelField("No Terrain Found!", centerLabel);
            EditorGUILayout.LabelField("Please add Terrain Component\nto this Game Object.", centerLabel);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();
        }

        //If the Terrain AND TerrainData is found, the actual Generator GUI is drawn
        else
        {
            terrainReso = t.terrainData.heightmapResolution;

            //This is the actual Generator script where we can input and output values from the GUI
            IslandGenerator script = (IslandGenerator)target;

            /***BEGIN GENERATOR BOX***/
            EditorGUILayout.BeginVertical("box");

            //If the Thread th1 is still running, it means shore calculation is still in progress,
            //so further map generation should be disabled for that time
            if (script.th1 != null && script.th1.ThreadState == System.Threading.ThreadState.Running)
            {
                GUI.enabled = false;
            }

            EditorGUILayout.LabelField("Generate Island", centerLabel);

            usedSeeds = script.usedSeeds;

            //This checks if user selects a seed from the Used Seeds list and replaces the current seed with it.
            EditorGUI.BeginChangeCheck();
            selected = EditorGUILayout.Popup("Used Seeds", selected, usedSeeds.ToArray());

            if (EditorGUI.EndChangeCheck())
            {
                script.seed = usedSeeds[selected];
            }

            script.seed              = EditorGUILayout.TextField(seedContent, script.seed);
            script.useRandomSeed     = EditorGUILayout.Toggle(useSeedContent, script.useRandomSeed);
            script.randomFillPercent = EditorGUILayout.IntSlider(randomFillContent, script.randomFillPercent, 30, 70);

            //If the shore radius changes, shores needs to be calculated again before adding them,
            //so the Add Shores Button will be disabled if the value here changes.
            EditorGUI.BeginChangeCheck();
            script.maxRadius = EditorGUILayout.IntSlider(maxRadiusContent, script.maxRadius, 25, 200);
            if (EditorGUI.EndChangeCheck())
            {
                shoresCalculated = false;
                script.prog      = "0%";
            }

            script.mapSmoothTimes = EditorGUILayout.IntField(smoothTimesContent, script.mapSmoothTimes);

            //Button to Generate basemap.
            if (GUILayout.Button(generateContent))
            {
                if (terrainReso < 129)
                {
                    Debug.LogWarning("Terrain Resolution is too small! Please use resolutions of 129 and higher.");
                }
                else
                {
                    Undo.RegisterUndo(terraini, "Generated New Map");
                    shoresCalculated = false;
                    script.StartGeneration();
                    script.prog = "0%";

                    //If the Used Seeds list doesn't contains current seed already
                    //we add that seed to the list.
                    if (!usedSeeds.Contains(script.seed))
                    {
                        usedSeeds.Insert(0, script.seed);
                    }
                    //Else if the seed exists in the list (e.g. same custom seed is used twice)
                    //we move the seed to the top.
                    else
                    {
                        usedSeeds.RemoveAt(usedSeeds.IndexOf(script.seed));
                        usedSeeds.Insert(0, script.seed);
                    }

                    //If there is more than 10 seeds, remove the oldest seed.
                    if (usedSeeds.Count > 10)
                    {
                        usedSeeds.RemoveAt(usedSeeds.Count - 1);
                    }

                    //After the button is pressed, change focus of the list to the latest seed.
                    selected = 0;
                }
            }

            EditorGUILayout.LabelField("Status", script.prog);

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button(calculateShoresContent))
            {
                script.CalculateShores();
            }

            //Progress of shore calculation is handled in the actual script, and when it reaches 100%
            //the "Add Shores" button can be enabled.
            if (script.prog == "100%")
            {
                shoresCalculated = true;
            }

            if (shoresCalculated && GUILayout.Button(addShoresContent))
            {
                Undo.RegisterUndo(terraini, "Added Shores");
                script.SmoothShores();

                //Smooths the map as many times as the user defines.
                for (int i = 0; i < script.mapSmoothTimes; i++)
                {
                    script.BlendHeights();
                }
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button(smoothOnceContent))
            {
                Undo.RegisterUndo(terraini, "Applied Smooth");
                script.BlendHeights();
            }

            GUI.enabled = true;

            if ((script.th1 != null && script.th1.ThreadState == System.Threading.ThreadState.Running) && GUILayout.Button("Abort"))
            {
                script.aborted   = true;
                shoresCalculated = false;
            }

            EditorGUILayout.EndVertical();
            /***END GENERATOR BOX***/

            EditorGUILayout.Space();

            /***BEGIN PERLIN NOISE BOX***/
            EditorGUILayout.BeginVertical("box");

            EditorGUILayout.LabelField("Add Perlin Noise", centerLabel);
            script.perlinHeight = EditorGUILayout.FloatField(heightContent, script.perlinHeight);
            script.perlinScale  = EditorGUILayout.FloatField(scaleContent, script.perlinScale);

            if (GUILayout.Button(addPerlinContent))
            {
                Undo.RegisterUndo(terraini, "Applied Perlin Noise");
                script.PerlinNoise();
            }
            if (GUILayout.Button(lowerSeaContent))
            {
                Undo.RegisterUndo(terraini, "Lowered Heightmap");
                script.ResetSeaFloor();
            }
            EditorGUILayout.EndVertical();
            /***END PERLIN NOISE BOX***/

            EditorGUILayout.Space();

            /***BEGIN PRESETS BOX***/
            EditorGUILayout.BeginVertical("box");

            EditorGUILayout.LabelField("Some preset noises  ", centerLabel);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Many Low Bumps"))
            {
                Undo.RegisterUndo(terraini, "Applied Perlin Noise");
                script.perlinHeight = 0.001f;
                script.perlinScale  = 75;
                script.PerlinNoise();
            }
            if (GUILayout.Button("Many High Bumps"))
            {
                Undo.RegisterUndo(terraini, "Applied Perlin Noise");
                script.perlinHeight = 0.005f;
                script.perlinScale  = 100;
                script.PerlinNoise();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Few Low Bumps"))
            {
                Undo.RegisterUndo(terraini, "Applied Perlin Noise");
                script.perlinHeight = 0.01f;
                script.perlinScale  = 20;
                script.PerlinNoise();
            }
            if (GUILayout.Button("Few High Bumps"))
            {
                Undo.RegisterUndo(terraini, "Applied Perlin Noise");
                script.perlinHeight = 0.015f;
                script.perlinScale  = 25;
                script.PerlinNoise();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            /***END BOX***/
        }
    }