public ToskaSubComposition CreateSubCompositionCandidate() { // width // height var comp = new ToskaSubComposition(); var numlines = Random.Range(MIN_LINE_NUM, height / 2); var startLength = Random.Range(MIN_LENGTH, (int)(width * 0.66)); var startX = Random.Range(0, width - startLength); var startY = Random.Range(0, height - 2 * numlines); var inflectionPoints = new RangeInt(0, numlines).Choose(Random.Range(0, 3)); //var inflectionPoints = [1, 4, 6]; var currX = startX; var currY = startY; var currLen = startLength; foreach (var i in inflectionPoints) { while (comp.lines.Count < i) { var line = new ToskaLine(); line.start = new Coord(currX, currY); line.end = new Coord(currX + currLen, currY); currY += 2; comp.lines.Add(line); } var newLen = Random.Range(MIN_LENGTH, (int)(width * 0.66)); // keep left or right currX = Random.value > 0.5 ? currX : currX + newLen - currLen; currLen = newLen; } return(comp); }
public void RenderLine(ToskaLine c, Color color) { for (int x = c.start.x; x <= c.end.x; x++) { for (int y = c.start.y; y <= c.end.y; y++) { var g = board.FindGraphicAtPosition(x, y); if (g != null) { g.SetColor(color, 2); } } } }