Ejemplo n.º 1
0
 /// <summary>
 /// returns where new unit of specified type can move out of the way after specified path makes it
 /// </summary>
 /// <remarks>chooses a random location between makeUnitMinDist and makeUnitMaxDist away from path</remarks>
 private FP.Vector makeUnitMovePos(long time, Path path, UnitType type)
 {
     FP.Vector ret;
     do {
         ret = new FP.Vector((long)((UnityEngine.Random.value - 0.5) * type.makeUnitMaxDist * 2),
             (long)((UnityEngine.Random.value - 0.5) * type.makeUnitMaxDist * 2));
     } while (ret.lengthSq() < type.makeUnitMinDist * type.makeUnitMinDist
         || ret.lengthSq() > type.makeUnitMaxDist * type.makeUnitMaxDist);
     return ret + path.posWhen(time);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// returns where new path with specified units can move out of the way after specified path makes it
 /// </summary>
 /// <remarks>chooses a random location between makePathMinDist() and makePathMaxDist() away from path</remarks>
 private FP.Vector makePathMovePos(long time, Path path, List<Unit> units)
 {
     long makePathMinDist = path.makePathMinDist (time, units);
     long makePathMaxDist = path.makePathMaxDist (time, units);
     FP.Vector ret;
     do {
         ret = new FP.Vector((long)((UnityEngine.Random.value - 0.5) * makePathMaxDist * 2),
             (long)((UnityEngine.Random.value - 0.5) * makePathMaxDist * 2));
     } while (ret.lengthSq() < makePathMinDist * makePathMinDist
         || ret.lengthSq() > makePathMaxDist * makePathMaxDist);
     return ret + path.posWhen(time);
 }