Example #1
0
  private void popPrey() {
    if (list.size() >= maxPrey) return;

    Entity prey = new Entity(getOwner().getEngine(), Engine.getDefaultShape());
    Prey preyA = new Prey(prey);
    preyA.setLife(160);
    preyA.setFood(100);
    prey.addAbility(preyA);

    ShapeMove move = new ShapeMove(prey);
    move.setSpeed(2);
    move.setArea(getArea());
    prey.addAbility(move);

    RealRender render = new RealRender(prey);
    render.setAnimation(getOwner().getEngine().getRessources().getAnimation("Prey"));
    prey.addAbility(render);

    Vector2f position = new Vector2f(getArea().getCenterX(), getArea().getCenterY());

    prey.setPosition(position);
    prey.setDirection(270);

    getOwner().getEngine().addEntityToBuff(prey);
    list.add(prey);
  }
Example #2
0
  // Method that allows Predator to kill its Prey
  public void eat(Object p) {

    if (p.getClass().equals(Prey.class)) {
      Prey prey = (Prey) p;
      if (prey.isDiseased()) this.setDisease(true);
      lastMeal = 0;
      // System.out.println(this + " ate " + p);
      grid.remove(p);
    }
  }