private void UpdateRoadMode()
 {
     if (RoadModeIgnore.Value)
     {
         _hexMapEditor.SetRoadMode(0);
     }
     else if (RoadModeYes.Value)
     {
         _hexMapEditor.SetRoadMode(1);
     }
     else if (RoadModeNo.Value)
     {
         _hexMapEditor.SetRoadMode(2);
     }
 }
        public IEnumerator chooseRoadTest()
        {
            SceneManager.LoadScene("Scene", LoadSceneMode.Single);
            yield return(new WaitForSeconds(1.0f));

            GameObject[] go = SceneManager.GetActiveScene().GetRootGameObjects();

            HexMapEditor editor = go[3].transform.Find("Hex Map Editor").GetComponent <HexMapEditor>();
            HexGrid      grid   = go[1].gameObject.GetComponent <HexGrid>();

            HexGridChunk[] chunks    = grid.getHexGridChunks();
            HexCell[]      cells     = chunks[0].getCells();
            HexDirection   direction = HexDirection.NE;
            HexCell        cell      = cells[4].GetNeighbor(direction).GetNeighbor(direction)
                                       .GetNeighbor(direction);
            HexCell neighbor = cell.GetNeighbor(HexDirection.E);

            int elevationLevel = 1;

            editor.SetApplyElevation(true);
            editor.SetElevation(elevationLevel);
            editor.HandleTestInput(cell);

            editor.SetApplyElevation(false);
            editor.SetRoadMode((int)HexMapEditor.OptionalToggle.Yes);
            editor.HandleTestInput(neighbor);

            Assert.IsTrue(cell.HasRoadThroughEdge(HexDirection.E));
            Assert.IsTrue(neighbor.HasRoadThroughEdge(HexDirection.W));

            editor.SetRoadMode((int)HexMapEditor.OptionalToggle.No);
            editor.HandleTestInput(neighbor);

            Assert.IsFalse(cell.HasRoadThroughEdge(HexDirection.E));
            Assert.IsFalse(neighbor.HasRoadThroughEdge(HexDirection.W));

            foreach (GameObject g in go)
            {
                GameObject.Destroy(g);
            }
            SceneManager.UnloadScene("Scene");
        }
Ejemplo n.º 3
0
    private static void RoadCommands(string command)
    {
        switch (command)
        {
        case "Active":
            editor.SetRoadMode(1);
            break;

        case "Inactive":
            editor.SetRoadMode(2);
            break;

        case "Ignore":
            editor.SetRoadMode(0);
            break;

        default: Debug.Log("Console Command Failure");
            break;
        }
    }
Ejemplo n.º 4
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;
        }
    }