コード例 #1
0
ファイル: Itinerary.java プロジェクト: benbardin/isnork
  protected PointOfInterest standingOrder(Point2D whereIAm) {
    Point2D target =
        new Point2D.Double(
            whereIAm.getX() + (spiralHeading.getDx() * MOVEMENT_LENGTH),
            whereIAm.getY() + (spiralHeading.getDy() * MOVEMENT_LENGTH));

    while (!StaticDiver.pointIsOnBoard(target.getX(), target.getY(), boardRadius)) {
      switch (spiralHeading) {
        case N:
          spiralHeading = Direction.W;
          break;
        case E:
          spiralHeading = Direction.N;
          break;
        case S:
          spiralHeading = Direction.E;
          break;
        case W:
          spiralHeading = Direction.S;
          break;
      }

      target =
          new Point2D.Double(
              whereIAm.getX() + (spiralHeading.getDx() * MOVEMENT_LENGTH),
              whereIAm.getY() + (spiralHeading.getDy() * MOVEMENT_LENGTH));
    }

    return new PointOfInterest(target);
  }
コード例 #2
0
ファイル: Itinerary.java プロジェクト: benbardin/isnork
 public void tick(Point2D whereIAm) {
   PointOfInterest poi;
   for (Iterator<PointOfInterest> i = goals.iterator(); i.hasNext(); ) {
     poi = i.next();
     poi.age();
     if (poi.getAge() > AGE_THRESHOLD
         || StaticDiver.getDistanceFromCreature(poi.getLocation(), whereIAm)
             < DISTANCE_THRESHOLD) {
       i.remove();
     }
   }
 }