Exemple #1
0
    private void Update()
    {
        HexMapEditor mapEditor = HexMapEditor;

        if (mapEditor != null && !m_haveBuilt)
        {
            for (int i = 0; i < TerrainIterations; ++i)
            {
                HexCell hexCell = mapEditor.HexGrid.GetRandomCell();

                int brushSize   = Random.Range(1, 4);
                int elevation   = Random.Range(1, 3);
                int terrainType = Random.Range(0, 5);

                mapEditor.SetBrushSize(brushSize);
                mapEditor.SetElevation(elevation);
                mapEditor.SetTerrainType(terrainType);
                //mapEditor.SE(color);
                mapEditor.EditCells(hexCell);
            }

            if (Rivers)
            {
                BuildRiverOrRoad(mapEditor, NumRivers, 8, 15, false);
            }

            if (Roads)
            {
                BuildRiverOrRoad(mapEditor, NumRoads, 8, 15, true);
            }

            if (Water)
            {
                for (int i = 0; i < NumWater; ++i)
                {
                    HexCell hexCell = mapEditor.HexGrid.GetRandomCell();

                    int brushSize  = Random.Range(1, 4);
                    int waterLevel = Random.Range(0, 2);

                    mapEditor.SetBrushSize(brushSize);
                    mapEditor.SetWaterLevel(waterLevel);
                    mapEditor.SetApplyElevation(false);
                    mapEditor.SetApplyWaterLevel(true);
                    mapEditor.EditCells(hexCell);
                }
            }
            mapEditor.SetBrushSize(1);
            mapEditor.SetApplyElevation(false);
            mapEditor.SetApplyWaterLevel(false);
            mapEditor.SetRiverMode((int)OptionalToggle.Ignore);
            mapEditor.SetRoadMode((int)OptionalToggle.Ignore);

            for (int i = 0; i < UrbanFeatureIterations; ++i)
            {
                HexCell hexCell = mapEditor.HexGrid.GetRandomCell();
                hexCell.UrbanDensityLevel = Random.Range(1, 4);
                hexCell.FarmDensityLevel  = Random.Range(1, 4);
                hexCell.PlantDensityLevel = Random.Range(1, 4);
            }

            for (int i = 0; i < NumWalls; ++i)
            {
                HexCell hexCell = mapEditor.HexGrid.GetRandomCell();
                hexCell.Walled = true;
            }

            for (int i = 0; i < NumSpecials; ++i)
            {
                HexCell hexCell = mapEditor.HexGrid.GetRandomCell();
                hexCell.SpecialFeatureIndex = Random.Range(1, 4);
            }


            for (int i = 0; i < NumUnits; ++i)
            {
                HexCell hexCell = mapEditor.HexGrid.GetRandomCell();
                mapEditor.CreateUnit(hexCell);
            }

            m_haveBuilt = true;
        }
    }