public void Generate(bool randomizeConfig = true) { if (constantSeed) { Random.InitState(0); } if (randomizeConfig) { GeneratePalette(); config.palette.wallColor = GetMainColorHSV().ToColor(); config.roofConfig.type = RandomE.GetRandom(RoofType.Flat, RoofType.Hipped, RoofType.Gabled); } if (generator == null) { generator = new BuildingGenerator(); } var buildingDraft = generator.Generate(config); AssignDraftToMeshFilter(buildingDraft, buildingMeshFilter, ref buildingMesh); float buildingRadius = Mathf.Sqrt(config.length / 2 * config.length / 2 + config.width / 2 * config.width / 2); float platformRadius = buildingRadius + platformRadiusOffset; var platformDraft = Platform(platformRadius, platformHeight); AssignDraftToMeshFilter(platformDraft, platformMeshFilter, ref platformMesh); }
public void WithEmptyArray() { for (int i = 0; i < 100; i++) { Assert.Contains(RandomE.GetRandom(0, 1, emptyArray), array01); } }
private IEnumerator GenerateCoroutine() { var algorithm = generatorAlgorithm; if (algorithm == MazeGenerator.Algorithm.None) { algorithm = RandomE.GetRandom(MazeGenerator.Algorithm.RandomTraversal, MazeGenerator.Algorithm.RandomDepthFirstTraversal, MazeGenerator.Algorithm.RandomBreadthFirstTraversal); } hue = Random.value; switch (algorithm) { case MazeGenerator.Algorithm.RandomTraversal: yield return(StartCoroutine(mazeGenerator.RandomTraversal(DrawEdge, texture.Apply))); break; case MazeGenerator.Algorithm.RandomDepthFirstTraversal: yield return(StartCoroutine(mazeGenerator.RandomDepthFirstTraversal(DrawEdge, texture.Apply))); break; case MazeGenerator.Algorithm.RandomBreadthFirstTraversal: yield return(StartCoroutine(mazeGenerator.RandomBreadthFirstTraversal(DrawEdge, texture.Apply))); break; } texture.Apply(); }
public void WithArray() { for (int i = 0; i < 100; i++) { Assert.Contains(RandomE.GetRandom(0, 1, array23), array0123); } }
public void NoParams() { for (int i = 0; i < 100; i++) { Assert.Contains(RandomE.GetRandom(0, 1), array01); } }
private IEnumerator GenerateCoroutine() { var algorithm = generatorAlgorithm; if (algorithm == MazeGenerator.Algorithm.None) { algorithm = RandomE.GetRandom(MazeGenerator.Algorithm.RandomTraversal, MazeGenerator.Algorithm.RandomDepthFirstTraversal, MazeGenerator.Algorithm.RandomBreadthFirstTraversal); } hue = Random.value; var backgroundColor = new ColorHSV(hue, backgroundSaturation, backgroundValue).complementary.ToColor(); background.CrossFadeColor(backgroundColor, fadeDuration, true, false); switch (algorithm) { case MazeGenerator.Algorithm.RandomTraversal: yield return(StartCoroutine(mazeGenerator.RandomTraversal(DrawEdge, texture.Apply))); break; case MazeGenerator.Algorithm.RandomDepthFirstTraversal: yield return(StartCoroutine(mazeGenerator.RandomDepthFirstTraversal(DrawEdge, texture.Apply))); break; case MazeGenerator.Algorithm.RandomBreadthFirstTraversal: yield return(StartCoroutine(mazeGenerator.RandomBreadthFirstTraversal(DrawEdge, texture.Apply))); break; } texture.Apply(); }
private IEnumerator GenerateCoroutine() { var algorithm = generatorAlgorithm; if (algorithm == MazeGenerator.Algorithm.None) { algorithm = RandomE.GetRandom(MazeGenerator.Algorithm.RandomTraversal, MazeGenerator.Algorithm.RandomDepthFirstTraversal, MazeGenerator.Algorithm.RandomBreadthFirstTraversal); } hue = Random.value; // var backgroundColor = new ColorHSV(hue, backgroundSaturation, backgroundValue).complementary.ToColor(); // background.CrossFadeColor(backgroundColor, fadeDuration, true, false); switch (algorithm) { case MazeGenerator.Algorithm.RandomTraversal: yield return(StartCoroutine(mazeGenerator.RandomTraversal(DrawEdge, texture.Apply))); break; case MazeGenerator.Algorithm.RandomDepthFirstTraversal: yield return(StartCoroutine(mazeGenerator.RandomDepthFirstTraversal(DrawEdge, texture.Apply))); break; case MazeGenerator.Algorithm.RandomBreadthFirstTraversal: yield return(StartCoroutine(mazeGenerator.RandomBreadthFirstTraversal(DrawEdge, texture.Apply))); break; } texture.Apply(); if (onMazeGenerated != null) { onMazeGenerated(); } //byte[] bytes = texture.EncodeToPNG(); // For testing purposes, also write to a file in the project folder //File.WriteAllBytes(Application.dataPath + "/../SavedScreen.png", bytes); }
private void Awake() { var generator = new BuildingGenerator(); generator.SetFacadePlanner(facadePlanner); generator.SetFacadeConstructor(facadeConstructor); generator.SetRoofPlanner(roofPlanner); generator.SetRoofConstructor(roofConstructor); float xOffset = (xCount - 1) * 0.5f * cellSize; float zOffset = (zCount - 1) * 0.5f * cellSize; for (int z = 0; z < zCount; z++) { for (int x = 0; x < xCount; x++) { config.roofConfig.type = RandomE.GetRandom(RoofType.Flat, RoofType.Hipped, RoofType.Gabled); var building = generator.Generate(foundationPolygon.vertices, config); building.position = new Vector3(x * cellSize - xOffset, 0, z * cellSize - zOffset); } } }
public void NullArrayThrowsException() { Assert.Catch <ArgumentNullException>(() => RandomE.GetRandom(0, 1, nullArray)); }