static private void createPaths() { Debug.LogWarning("Creating Paths..."); if (errorStatus) { return; } //Get Points List <Vector2> levelPoints = new List <Vector2>(); for (int y = 0; y < rows.value; y++) { for (int x = 0; x < cols.value; x++) { if (levelArray[x, y].type != (int)eDGModuleType.NONE) { levelPoints.Add(new Vector2(x, y)); } } } //Shuffle Points List <Vector2> levelPointsSorted = new List <Vector2>(); for (int i = 0; i < levelPoints.Count; i++) { while (true) { Vector2 point = levelPoints[DGRandom.Range(0, levelPoints.Count)]; if (levelPointsSorted.IndexOf(point) == -1) { levelPointsSorted.Add(point); break; } } } //Connect points string output = ""; for (int i = 1; i < levelPointsSorted.Count; i++) { createConnectedPoints(levelPointsSorted[i], levelPointsSorted[i - 1], ref output); output += "\n"; } Debug.Log(output); Debug.Log("All Paths Created!"); debugLevelModules(); }
static private void createAccesses() { Debug.LogWarning("Creating accesses..."); if (errorStatus) { return; } string output = ""; for (int i = 0; i < accesses.value; i++) { bool created = false; while (!created) { int x = 0; int y = 0; //Access on the X axis (cols) if (DGRandom.Range(0, 2) == 0) { x = (DGRandom.Range(0, 2) == 0) ? 0 : cols.value - 1; y = DGRandom.Range(0, rows.value); } //Access on the Y axis (rows) else { x = DGRandom.Range(0, cols.value); y = (DGRandom.Range(0, 2) == 0) ? 0 : rows.value - 1; } //Check Availability if (levelArray[x, y].type == (int)eDGModuleType.NONE) { //CREATE created = true; output += "Access #" + i + " x:" + x + " y:" + y + "\n"; levelArray[x, y].type = (int)eDGModuleType.ACCESS; accessesList.Add(new Vector2(x, y)); } } } Debug.Log(output); debugLevelModules(); }