-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tower.java
75 lines (60 loc) · 1.61 KB
/
Tower.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
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
package GameObjects;
import org.newdawn.slick.opengl.Texture;
import java.util.Random;
import static helpers.Artist.*;
import data.*;
public class Tower {
final static int MAXLEVEL = 5;
private String name;
private int baseattack;
private int maxattack;
private double range;
private int tcost;
private int upcost;
private int level;
private Texture texture;
private TowerType type;
private Tile startTile;
private float x, y, width, hight;
public Tower(String name, Tile startTile, TowerType type){
this.name = name;
this.startTile = startTile;
this.x = startTile.getX();
this.y = startTile.getY();
this.type = type;
this.baseattack = type.baseattack;
this.maxattack = type.maxattack;
this.tcost = type.tcost;
this.upcost = type.upcost;
this.level = 1;
this.texture = QuickLoad(type.texture);
this.range = type.range;
this.width = startTile.getWidth();
this.hight = startTile.getHight();
}
public void DrawTower(){
DrawQuadTex(this.texture, this.x, this.y, this.width, this.hight);
}
public int Attack() {
Random rand = new Random();
return rand.nextInt(this.maxattack) + this.baseattack;
}
public void UpgradeTower() throws MaxLevelReachedException {
if (this.level != MAXLEVEL) {
this.level = this.level + 1;
this.baseattack = this.baseattack + 5;
this.maxattack = this.maxattack + 5;
} else {
throw new MaxLevelReachedException();
}
}
public int getTcost() {
return tcost;
}
public double getRange() {
return range;
}
public int getUpcost() {
return upcost;
}
}