예제 #1
0
        /**
         * Makes a square of player locations. Places players in a square, which automatically adjusts to a rectangle for rectangular maps.
         * Unlike the circle, variance here is determined by a plus or minus (the distVariation) off of the mean distance.
         * SpacingVariation determines whether players are equidistant or can be slightly closer or farther apart.
         */
        public void rmPlacePlayersSquare(float dist, float distVariation, float spacingVariationfloat)
        {
            XVector2  min  = new XVector2(MapSizeX * dist / 2, MapSizeZ * dist / 2);
            XVector2  max  = new XVector2(MapSizeX - min.X, MapSizeZ - min.Y);
            RMPolygon poly = new RMPolygon()
            {
                Points = new[] {
                    new XVector2(min.X, min.Y), new XVector2(min.X, max.Y),
                    new XVector2(max.X, max.Y), new XVector2(max.X, min.Y)
                }
            };
            float polyLen = poly.Length;
            float off     = (float)rand.NextDouble();

            for (int p = 1; p < players.Count; ++p)
            {
                players[p].Position =
                    fracToMeters(tileToFrac(poly.GetPointAlongSurface(
                                                ((p - 1 + off) / (players.Count - 1)) * polyLen)
                                            ));
            }
        }
예제 #2
0
 /**
  * Makes a square of player locations. Places players in a square, which automatically adjusts to a rectangle for rectangular maps.
  * Unlike the circle, variance here is determined by a plus or minus (the distVariation) off of the mean distance.
  * SpacingVariation determines whether players are equidistant or can be slightly closer or farther apart.
  */
 public void rmPlacePlayersSquare(XReal dist, XReal distVariation, XReal spacingVariationfloat)
 {
     XReal half = (XReal)0.5f;
     XVector2 min = new XVector2(TileSizeX * (half - dist), TileSizeZ * (half - dist));
     XVector2 max = new XVector2(TileSizeX - min.X, TileSizeZ - min.Y);
     RMPolygon poly = new RMPolygon() {
         Points = new[] {
             new XVector2(min.X, min.Y), new XVector2(min.X, max.Y),
             new XVector2(max.X, max.Y), new XVector2(max.X, min.Y)
         }
     };
     XReal polyLen = poly.Length;
     XReal off = (XReal)rand.NextDouble();
     for (int p = 1; p < players.Count; ++p) {
         players[p].Position =
             fracToMeters(tileToFrac(poly.GetPointAlongSurface(
                 ((p - 1 + off) / (players.Count - 1)) * polyLen)
             ));
     }
 }