-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChief.java
41 lines (33 loc) · 1.31 KB
/
Chief.java
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
29
30
31
32
33
34
35
36
37
38
39
40
41
import processing.core.PImage;
import java.util.List;
public abstract class Chief extends MovingEntities{
private final int resourceLimit;
private int resourceCount;
public Chief(String id, Point position, List<PImage> images, int resourceLimit, int resourceCount, int actionPeriod, int animationPeriod){
super(id, position, images, actionPeriod, animationPeriod);
this.resourceLimit = resourceLimit;
this.resourceCount = resourceCount;
}
protected int getResourceLimit(){
return resourceLimit;
}
protected int getResourceCount(){
return resourceCount;
}
protected void addResourceCount(){
this.resourceCount += 1;
}
protected Point nextPosition(WorldModel world, Point destPos)
{
List<Point> newPos = this.pathingStrategy.computePath(this.getPosition(), destPos, p -> world.withinBounds(p) &&
(!world.isOccupied(p) || world.getOccupant(p).get().getClass() == Grunt.class),
(p1, p2) -> world.adjacent(p1, p2), PathingStrategy.CARDINAL_NEIGHBORS);
if (newPos.isEmpty()){
return this.getPosition();
}
else{
return newPos.get(0);
}
}
protected abstract boolean transform(WorldModel world, EventScheduler scheduler, ImageStore imageStore);
}