This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tower.pde
70 lines (54 loc) · 1.39 KB
/
Tower.pde
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
abstract class Tower extends CBeing {
public static final int MELEE = 0;
public static final int ARROW = 1;
public static final int ICE = 2;
public static final int SIZE = Node.SIZE;
public static final String DIR = "towers";
public static final int RANGE = 130;
public static final int Y_OFFSET = -49;
protected Game game;
protected Player player;
protected Node node;
protected int type;
protected PImage sprite;
protected int lvl = 1;
protected TowerStats stats;
private color background;
Tower(int type, Node node, Player player, Game game) {
super(node.getShape());
this.game = game;
this.player = player;
this.node = node;
this.type = type;
_setTypeProps(type);
}
public int getType() {
return type;
}
public TowerStats getStats() {
return stats;
}
void draw() {
noStroke();
image(sprite, 0, Y_OFFSET);
}
protected void _register() {
node.unregister();
}
private void _setTypeProps(int type) {
switch (type) {
case ARROW:
sprite = assetManager.getImage("arrowTower");
stats = new ArrowTowerStats();
break;
case ICE:
sprite = assetManager.getImage("iceTower");
stats = new IceTowerStats();
break;
default:
sprite = assetManager.getImage("arrowTower");
stats = new ArrowTowerStats();
break;
}
}
}