Esempio n. 1
0
  @Override
  public void controlUpdate(float tpf, Monster monster, Area area) {
    secondsElapsed -= tpf;
    if (secondsElapsed < 0) {
      Moving a = new Moving();
      a.setRequiredDistance(0.5f);
      float dx = 10 - RandomUtil.nextInt(20);
      float dz = 10 - RandomUtil.nextInt(20);
      Vector3f destination = monster.getHome().add(dx, 0, dz);

      if (monster.getSpatial().getControl(GravityController.class) != null) {
        GravityController.correctPosition(destination, monster.getSpatial(), area.getScene());
      }

      a.setDestination(destination);
      monster.setBehavior(a);
      monster.getSprite().setInstantAnimation(Animation.WALK);
    }
  }
Esempio n. 2
0
    @Override
    public void update(Actor actor) {
      // update the activity
      Active active = (Active) actor;
      int activity = active.getActivity();
      int started = active.getActivityStarted();
      if (activity != _lastActivity || started > _lastActivityStarted) {
        activityChanged();
        Activity previous = _activity;
        Activity next = _activities.get(_lastActivity = activity);
        _lastActivityStarted = started;
        if (_activity != null) {
          _activity.stop(next);
        }
        if ((_activity = next) != null) {
          _activity.start(previous);
        }
      }
      if (_activity != null) {
        _activity.update();
      }

      super.update(actor);
    }
 public Coord getc() {
   Moving m = getattr(Moving.class);
   if (m != null) return (m.getc());
   else return (rc);
 }
 public void move(Coord c) {
   Moving m = getattr(Moving.class);
   if (m != null) m.move(c);
   this.rc = c;
 }