private void Awake() { var header = InstantiateControl <TextControl>(algorithmsGroup.transform.parent); header.Initialize("Generator algorithm"); header.transform.SetAsFirstSibling(); for (int i = 0; i < algorithms.Length; i++) { MazeGenerator.Algorithm algorithm = algorithms[i]; var toggle = InstantiateControl <ToggleControl>(algorithmsGroup.transform); toggle.Initialize( header: algorithmToString[algorithm], value: algorithm == generatorAlgorithm, onValueChanged: isOn => { if (isOn) { generatorAlgorithm = algorithm; Generate(); } }, toggleGroup: algorithmsGroup); } InstantiateControl <SliderControl>(leftPanel).Initialize("Cell Size", 1, 10, cellSize, value => { cellSize = value; Generate(); }); InstantiateControl <SliderControl>(leftPanel).Initialize("Wall Size", 1, 10, wallSize, value => { wallSize = value; Generate(); }); InstantiateControl <ToggleControl>(leftPanel).Initialize("Use gradient", useGradient, value => { useGradient = value; Generate(); }); InstantiateControl <ButtonControl>(leftPanel).Initialize("Generate new maze", Generate); Generate(); }
private void InstantiateToggle(MazeGenerator.Algorithm algorithm, string header) { var toggle = InstantiateControl <ToggleControl>(algorithmsGroup.transform); toggle.Initialize( header: header, value: algorithm == config.algorithm, onValueChanged: isOn => { if (isOn) { config.algorithm = algorithm; Generate(); } }, toggleGroup: algorithmsGroup); }
private void Start() { mapWidth = GameManager.Main.MainTerrain.terrainData.heightmapWidth; mapHeight = GameManager.Main.MainTerrain.terrainData.heightmapHeight; var header = InstantiateControl <TextControl>(algorithmsGroup.transform.parent); header.Initialize("Generator algorithm"); header.transform.SetAsFirstSibling(); foreach (MazeGenerator.Algorithm algorithm in algorithms) { var toggle = InstantiateControl <ToggleControl>(algorithmsGroup.transform); toggle.Initialize( header: algorithmToString[algorithm], value: algorithm == generatorAlgorithm, onValueChanged: isOn => { if (isOn) { generatorAlgorithm = algorithm; } }, toggleGroup: algorithmsGroup); } var cellSizeSlider = InstantiateControl <SliderControl>(leftPanel); cellSizeSlider.Initialize("Cell size", 1, 10, cellSize, value => cellSize = value); var wallSizeSlider = InstantiateControl <SliderControl>(leftPanel); wallSizeSlider.Initialize("Wall size", 1, 10, wallSize, value => wallSize = value); var useRainbowGradientToggle = InstantiateControl <ToggleControl>(leftPanel); useRainbowGradientToggle.Initialize("Use rainbow gradient", useRainbowGradient, value => useRainbowGradient = value); var generateButton = InstantiateControl <ButtonControl>(leftPanel); generateButton.Initialize("Generate new maze", Generate); Generate(); }
private void Awake() { var header = InstantiateControl<TextControl>(algorithmsGroup.transform.parent); header.Initialize("Generator algorithm"); header.transform.SetAsFirstSibling(); for (int i = 0; i < algorithms.Length; i++) { MazeGenerator.Algorithm algorithm = algorithms[i]; var toggle = InstantiateControl<ToggleControl>(algorithmsGroup.transform); toggle.Initialize( header: algorithmToString[algorithm], value: algorithm == generatorAlgorithm, onValueChanged: isOn => { if (isOn) { generatorAlgorithm = algorithm; Generate(); } }, toggleGroup: algorithmsGroup); } InstantiateControl<SliderControl>(leftPanel).Initialize("Cell size", 1, 10, cellSize, value => { cellSize = value; Generate(); }); InstantiateControl<SliderControl>(leftPanel).Initialize("Wall size", 1, 10, wallSize, value => { wallSize = value; Generate(); }); InstantiateControl<ToggleControl>(leftPanel).Initialize("Use gradient", useGradient, value => { useGradient = value; Generate(); }); InstantiateControl<ButtonControl>(leftPanel).Initialize("Generate new maze", Generate); Generate(); }
public void TimeComparison() { using (System.IO.StreamWriter file = new System.IO.StreamWriter(@Application.dataPath + "/Tiempos.csv")) { StatComparison <int> Test = new StatComparison <int>(); StringBuilder sb = new StringBuilder(); sb.Clear(); sb.Append("Algorithm,Size,Time(ms)\n"); file.Write(sb.ToString()); int size = 50; int maxsize = 100; int inc = 10; //int rows = size; //int cols = size; TimeSpan stop; TimeSpan start; while (size <= maxsize) { G = MazeGraph <int> .CreateNoWallsGraph4(size, size); for (int i = 0; i < 10; i++) { foreach (MazeGenerator.Algorithm it in Enum.GetValues(typeof(MazeGenerator.Algorithm))) { sb.Clear(); generationAlgorithm = it; start = new TimeSpan(DateTime.Now.Ticks); executeAlgorithm(); stop = new TimeSpan(DateTime.Now.Ticks); sb.Append(it + "," + (size + "x" + size) + "," + stop.Subtract(start).TotalMilliseconds.ToString("00.000", CultureInfo.InvariantCulture) + "\n"); file.Write(sb.ToString()); } } size = size + inc; } } }
private void Awake() { var header = InstantiateControl<TextControl>(algorithmsGroup.transform.parent); header.Initialize("Generator algorithm"); header.transform.SetAsFirstSibling(); foreach (MazeGenerator.Algorithm algorithm in algorithms) { var toggle = InstantiateControl<ToggleControl>(algorithmsGroup.transform); toggle.Initialize( header: algorithmToString[algorithm], value: algorithm == generatorAlgorithm, onValueChanged: isOn => { if (isOn) { generatorAlgorithm = algorithm; } }, toggleGroup: algorithmsGroup); } var cellSizeSlider = InstantiateControl<SliderControl>(leftPanel); cellSizeSlider.Initialize("Cell size", 1, 10, cellSize, value => cellSize = value); var wallSizeSlider = InstantiateControl<SliderControl>(leftPanel); wallSizeSlider.Initialize("Wall size", 1, 10, wallSize, value => wallSize = value); var useRainbowGradientToggle = InstantiateControl<ToggleControl>(leftPanel); useRainbowGradientToggle.Initialize("Use rainbow gradient", useRainbowGradient, value => useRainbowGradient = value); var generateButton = InstantiateControl<ButtonControl>(leftPanel); generateButton.Initialize("Generate new maze", Generate); Generate(); }
private void SetupAlgorithmToggle(Toggle toggle, MazeGenerator.Algorithm algorithm) { toggle.isOn = algorithm == generatorAlgorithm; toggle.name = algorithm.ToString(); toggle.GetComponentInChildren<Text>().text = algorithmToString[algorithm]; toggle.onValueChanged.AddListener(isOn => { if (isOn) { generatorAlgorithm = algorithm; } }); }