예제 #1
0
  public synchronized void tick() {
    if (!isFollowing()) return;

    if (isDemoMode()) {
      if (hasBeenDemoTrackingFor(DEMO_MODE_FOCUS_TIME_IN_SECONDS + DEMO_MODE_ZOOM_TIME_IN_SECONDS))
        startTrackingRandomLivingThing();
      else if (hasBeenDemoTrackingFor(DEMO_MODE_FOCUS_TIME_IN_SECONDS)) viewport.zoomOut();
    }

    if (target.getLabel().equals("narjillo")) {
      Narjillo narjillo = (Narjillo) target;
      if (narjillo.isDead()) {
        if (isDemoMode()) startTrackingRandomLivingThing();
        else {
          Thing nextClosestNarjillo = locator.findNarjilloAt(narjillo.getPosition());
          if (nextClosestNarjillo == null) {
            stopTracking();
            return;
          } else startTracking(nextClosestNarjillo);
        }
      }
    }

    if (target.getLabel().equals("egg")) {
      Narjillo hatched = ((Egg) target).getHatchedNarjillo();
      if (hatched != null) startTracking(hatched);
      return;
    }

    if (target.getLabel().equals("food_pellet")) {
      Thing eater = ((FoodPellet) target).getEater();
      if (eater != null) startTracking(eater);
      return;
    }

    viewport.centerOn(target);
  }
예제 #2
0
 @Override
 protected String getTypeTag(Thing obj) {
   return obj.getLabel();
 }