示例#1
0
 public boolean isPlaceEmpty(Vector2 pos, boolean considerPlanets) {
   Planet np = myPlanetManager.getNearestPlanet(pos);
   if (considerPlanets) {
     boolean inPlanet = np.getPos().dst(pos) < np.getFullHeight();
     if (inPlanet) return false;
   }
   SolSystem ns = myPlanetManager.getNearestSystem(pos);
   if (ns.getPos().dst(pos) < SunSingleton.SUN_HOT_RAD) return false;
   List<SolObject> objs = myObjectManager.getObjs();
   for (int i = 0, objsSize = objs.size(); i < objsSize; i++) {
     SolObject o = objs.get(i);
     if (!o.hasBody()) continue;
     if (pos.dst(o.getPos()) < myObjectManager.getRadius(o)) {
       return false;
     }
   }
   List<FarObjData> farObjs = myObjectManager.getFarObjs();
   for (int i = 0, farObjsSize = farObjs.size(); i < farObjsSize; i++) {
     FarObjData fod = farObjs.get(i);
     FarObj o = fod.fo;
     if (!o.hasBody()) continue;
     if (pos.dst(o.getPos()) < o.getRadius()) {
       return false;
     }
   }
   return true;
 }
示例#2
0
 @Override
 public boolean update(SolGame game, SolShip owner, boolean tryToUse) {
   myShouldTeleport = false;
   if (!tryToUse) return false;
   Vector2 pos = owner.getPos();
   Fraction frac = owner.getPilot().getFraction();
   SolShip ne = game.getFractionMan().getNearestEnemy(game, MAX_RADIUS, frac, pos);
   if (ne == null) return false;
   Vector2 nePos = ne.getPos();
   Planet np = game.getPlanetMan().getNearestPlanet();
   if (np.isNearGround(nePos)) return false;
   for (int i = 0; i < 5; i++) {
     myNewPos.set(pos);
     myNewPos.sub(nePos);
     myAngle = myConfig.angle * SolMath.rnd(.5f, 1) * SolMath.toInt(SolMath.test(.5f));
     SolMath.rotate(myNewPos, myAngle);
     myNewPos.add(nePos);
     if (game.isPlaceEmpty(myNewPos, false)) {
       myShouldTeleport = true;
       return true;
     }
   }
   return false;
 }