private Body BuildHexagon(BodyRenderer renderer, Color[] colors, Hexagon hex, float radius, float spacing) { var pos = hex.GetPosition(spacing); pos += new Vector2(radius) * Rand.Sign(); var color = colors.RandomItem(); return BuildHexagon(renderer, color, pos, radius, spacing); }
private IEnumerable<Body> SpiralRingDistribution(BodyRenderer renderer, Color[] colors, Vector2 origin, float size, float spacing, int spiralRadius, float chance) { var hexagons = new List<Body>(); var center = new Hexagon(0, 0); var color = colors.RandomItem(); var pos = origin + center.GetPosition(spacing); //hexagons.Add(BuildHexagon(render, color, pos, size, spacing)); var ring = center.GetSpiralRing(spiralRadius); foreach (var hexagon in ring) { pos = origin + hexagon.GetPosition(spacing); var rand = Rand.Float(); if (rand < chance) { if (rand > chance / 2) continue; var newSize = size / 3; var newSpacing = spacing / 3; if (newSpacing > .5f) { hexagons.AddRange(SpiralRingDistribution(renderer, colors, pos, newSize, newSpacing, 1, chance)); } continue; } color = colors.RandomItem(); hexagons.Add(BuildHexagon(renderer, color, pos, size, spacing)); } return hexagons; }