/** * Makes a line of player locations. Sometimes you will want players to be placed in a line. * Anatolia places each team on a line, while Vinlandsaga places all players in a line. * Using a line placement is not easy because there may not be enough room for player areas or resources. * X and Z determine the starting and ending locations of the line. * DistVariation determines how far from the line player areas can vary, and spacingVariation determines how much space there is among points along the line where players are placed. */ public void rmPlacePlayersLine(float x1, float z1, float x2, float z2, float distVariation, float spacingVariation) { XVector2 p1 = new XVector2(x1, z1), p2 = new XVector2(x2, z2); for (int p = 1; p < players.Count; ++p) { players[p].Position = fracToMeters(XVector2.Lerp(p1, p2, (float)(p - 1) / (players.Count - 1))); } }
// Returns a point along the surface, expected f from 0 to Length public XVector2 GetPointAlongSurface(XReal f) { for (int p = 0; p < Points.Length; ++p) { XVector2 p1 = Points[p], p2 = Points[(p + 1) % Points.Length]; XReal len = XVector2.Distance(p1, p2); if (len > f) { return(XVector2.Lerp(p1, p2, f / len)); } f -= len; } throw new Exception("rmPolygon::GetPointAlongSurface(), f is not in range!"); }