public IEnumerator chooseAndSetWaterTest()
        {
            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);

            int waterLevel = 1;

            editor.SetApplyWaterLevel(true);
            editor.SetWaterLevel(waterLevel);
            editor.HandleTestInput(cell);

            Assert.AreEqual(waterLevel, editor.activeWaterLevel);

            foreach (GameObject g in go)
            {
                GameObject.Destroy(g);
            }
            SceneManager.UnloadScene("Scene");
        }
Ejemplo n.º 2
0
    private static void WaterCommands(string command)
    {
        if (command.Equals("Active"))
        {
            editor.SetApplyWaterLevel(true);
        }
        if (command.Equals("Inactive"))
        {
            editor.SetApplyWaterLevel(false);
        }
        int val = 0;

        if (Int32.TryParse(command, out val))
        {
            editor.SetWaterLevel(val);
        }
        else
        {
            Debug.Log("Console Command Failure");
        }
    }
Ejemplo n.º 3
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;
        }
    }
 public void WaterCheckboxClicked()
 {
     //Debug.Log("Elevation Checkbox Clicked: " + ElevationEnabled.Value);
     _hexMapEditor.SetApplyWaterLevel(WaterEnabled.Value);
 }