public Line(PositivePoint startPoint, LineType type, float nodeSize, PositivePoint worldSize) { this.startPoint = startPoint; this.type = type; this.nodeSize = nodeSize; this.worldSize = worldSize; }
private void GenerateBranchDownLeft(Line line) { int branchIterations = 0; PositivePoint pos = GetBranchStartPoint(line); while (branchIterations < properties.BranchLongitude && pos.y > 0 && pos.x > 0) { branchIterations++; if (Random.Range(0, 100) <= 50) { pos.y--; } else { pos.x--; } map[pos.x, pos.y] = SquareValue.FLOOR; } }
private void GenerateBranchUpRight(Line line) { int branchIterations = 0; PositivePoint pos = GetBranchStartPoint(line); while (branchIterations < properties.BranchLongitude && pos.y < worldMapSize.y - 1 && pos.x < worldMapSize.x - 1) { branchIterations++; if (Random.Range(0, 100) <= 50) { pos.y++; } else { pos.x++; } map[pos.x, pos.y] = SquareValue.FLOOR; } }
private PositivePoint GetBranchStartPoint(Line line) { PositivePoint result = new PositivePoint(0, 0); switch (line.Type) { case Line.LineType.HORIZONTAL: result.y = line.StartPoint.y; result.x = (uint)Random.Range(0, (int)worldMapSize.x); break; case Line.LineType.VERTICAL: result.y = (uint)Random.Range(0, (int)worldMapSize.y); result.x = line.StartPoint.x; break; default: break; } return(result); }