-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHouse.java
More file actions
78 lines (66 loc) · 1.99 KB
/
House.java
File metadata and controls
78 lines (66 loc) · 1.99 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import processing.core.PImage;
import java.util.List;
public class House implements Entities{
private EntityKind kind;
private String id;
private Point position;
private List<PImage> images;
private int imageIndex;
private int resourceLimit;
private int resourceCount;
private double actionPeriod;
private double animationPeriod;
private int health;
private int healthLimit;
public House(EntityKind kind, String id, Point position, List<PImage> images, int resourceLimit, int resourceCount, double actionPeriod, double animationPeriod, int health, int healthLimit) {
this.kind = kind;
this.id = id;
this.position = position;
this.images = images;
this.imageIndex = 0;
this.resourceLimit = resourceLimit;
this.resourceCount = resourceCount;
this.actionPeriod = actionPeriod;
this.animationPeriod = animationPeriod;
this.health = health;
this.healthLimit = healthLimit;
}
@Override
public EntityKind getentitykind() {
return this.kind;
}
@Override
public Point getposition() {
return this.position;
}
@Override
public PImage getCurrentImage(Entities entity) {
return this.images.get(this.imageIndex % this.images.size());
}
public String log(){
return this.id.isEmpty() ? null :
String.format("%s %d %d %d", this.id, this.position.x, this.position.y, this.imageIndex);
}
@Override
public int gethealth() {
return this.health;
}
@Override
public void sethealth(int health) {
this.health = health;
}
@Override
public String getid() {
return this.id;
}
public Point setposition(Point position){
this.position = position;
return this.position;
}
public void nextImage() {
this.imageIndex = this.imageIndex + 1;
}
public double getAnimationPeriod() {
return this.animationPeriod;
}
}