Example #1
0
 public DVector3 RandomSpawnPosition(DReal min, DReal max)
 {
     for (var attempt = 0; attempt < 100; attempt += 1)
     {
         var angle  = World.current.RandomValue() * 360;
         var radius = World.current.RandomRange(min, max);
         var x      = this.position.x + DReal.Cos(angle) * radius;
         var z      = this.position.z + DReal.Sin(angle) * radius;
         var height = World.current.map.Height(new DVector3(x, 0, z));
         var p      = new DVector3(x, height, z);
         if (World.current.navigation.Reachability(this.position) == World.current.navigation.Reachability(p))
         {
             return(p);
         }
     }
     UnityEngine.Debug.Log("Failed to generate random position.");
     return(this.position);
 }
Example #2
0
 public static DVector2 FromAngle(DReal radians)
 {
     return(new DVector2(DReal.Cos(radians), DReal.Sin(radians)));
 }