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"); }
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"); }