-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrownPig.java
More file actions
29 lines (20 loc) · 1.06 KB
/
GrownPig.java
File metadata and controls
29 lines (20 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import processing.core.PImage;
import java.util.List;
public class GrownPig extends Pig {
public GrownPig(String id, Point position, List<PImage> images, double actionPeriod, double animationPeriod, int health, int healthLimit) {
super(id, position, images, actionPeriod, animationPeriod, health, healthLimit);
}
public boolean transform(WorldModel world, EventScheduler scheduler, ImageStore imageStore) {
if (getHealth() <= 0) {
Bacon bacon = Factory.createBacon(WorldLoader.BACON_KEY + "_" + getId(), getPosition(), imageStore.getImageList(WorldLoader.BACON_KEY));
world.removeEntity(scheduler, this);
world.tryAddEntity(bacon);
return true;
}
return false;
}
public void scheduleActions(EventScheduler scheduler, WorldModel world, ImageStore imageStore){
scheduler.scheduleEvent(this, Factory.createActivityAction(this, world, imageStore), getActionPeriod());
scheduler.scheduleEvent(this, Factory.createAnimationAction(this, 0), getActionPeriod());
}
}