public IEnumerator chooseAndSetElevationTest() { 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 elevationLevel = 2; int brushSize = 2; editor.SetApplyElevation(true); editor.SetElevation(elevationLevel); editor.SetBrushSize(brushSize); editor.HandleTestInput(cell); Assert.AreEqual(elevationLevel, editor.activeElevation); Assert.AreEqual(brushSize, editor.brushSize); foreach (GameObject g in go) { GameObject.Destroy(g); } SceneManager.UnloadScene("Scene"); }
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"); }
private static void ElevationCommands(string command) { if (command.Equals("Active")) { editor.SetApplyElevation(true); } if (command.Equals("Inactive")) { editor.SetApplyElevation(false); } int val = 0; if (Int32.TryParse(command, out val)) { editor.SetElevation(val); } else { Debug.Log("Console Command Failure"); } }
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 ElevationValueChanged() { _hexMapEditor.SetElevation(Elevation.Value); }