-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinerNotFull.java
More file actions
53 lines (48 loc) · 1.25 KB
/
MinerNotFull.java
File metadata and controls
53 lines (48 loc) · 1.25 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import processing.core.PImage;
import java.util.List;
public class MinerNotFull
extends Miner
{
public MinerNotFull(String name, Point position, int rate,
int animation_rate, int resource_limit, List<PImage> imgs)
{
super(name, position, rate, animation_rate, resource_limit,
0, Ore.class, imgs);
}
public String toString()
{
return String.format("miner %s %d %d %d %d %d", getName(),
getPosition().x, getPosition().y, getResourceLimit(),
getRate(), getAnimationRate());
}
protected Miner transform(WorldModel world)
{
if (getResourceCount() < getResourceLimit())
{
return this;
}
else
{
return new MinerFull(getName(), getPosition(), getRate(),
getAnimationRate(), getResourceLimit(), getImages());
}
}
protected boolean move(WorldModel world, WorldEntity ore)
{
if (ore == null)
{
return false;
}
if (adjacent(getPosition(), ore.getPosition()))
{
setResourceCount(getResourceCount() + 1);
ore.remove(world);
return true;
}
else
{
world.moveEntity(this, nextPosition(world, ore.getPosition()));
return false;
}
}
}