-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTower.java
More file actions
105 lines (96 loc) · 3.02 KB
/
Tower.java
File metadata and controls
105 lines (96 loc) · 3.02 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import com.googlecode.lanterna.terminal.Terminal.SGR;
import com.googlecode.lanterna.TerminalFacade;
import com.googlecode.lanterna.input.Key;
import com.googlecode.lanterna.input.Key.Kind;
import com.googlecode.lanterna.terminal.Terminal;
import com.googlecode.lanterna.terminal.Terminal.Color;
import com.googlecode.lanterna.terminal.TerminalSize;
import com.googlecode.lanterna.LanternaException;
import com.googlecode.lanterna.input.CharacterPattern;
import com.googlecode.lanterna.input.InputDecoder;
import com.googlecode.lanterna.input.InputProvider;
import com.googlecode.lanterna.input.Key;
import com.googlecode.lanterna.input.KeyMappingProfile;
import java.util.*;
public abstract class Tower{
int x, y; //x and y coordinates
int cost;
int radius; //range of the tower's attacks
Balloon target; //target of the tower
/**A Tower constructor
*@param int xCord is the x position of the tower, also its row in the array
*@param int yCord is the y position of the tower, also its column in the array
*@param int money is the cost
*@param int rad is the radius
*/
/* abstract Tower(int xCord, int yCord, int money, int rad){
x = xCord;
y = yCord;
cost = money;
radius = rad;
findVicinity();
}
*/
/**A method to get the x-coordinate of the tower on the map
*@return int
*/
public int getX(){
return x;
}
/**A method to get the y-coordinate of the tower on the map
*@return int
*/
public int getY(){
return y;
}
/**A method to get the cost of the tower
*@return int
*/
public int getCost(){
return cost;
}
/**A method to get the radius of the tower
*@return int
*/
public int getRadii(){
return radius;
}
/**A method to be written by the individual towers
*attacks are different for each type of tower
*/
/**A method to find a balloon target for the tower
*the balloon target is the nearest balloon on a road tile within the radius of the tower
*@return Balloon
*/
/*
public Balloon findTarget(List<Tile> roads){
double distance = (radius * radius) + 1;
Tile temp;
Tile targetTile = new Tile(0,0);
for(int i = 0; i < roads.size(); i++){
temp = roads.get(i);
if(temp.getHasBalloon()){
double distTemp = Math.pow(this.getX() - temp.getX(), 2) + Math.pow(this.getY() - temp.getY(), 2);
if(distTemp < distance){
distance = distTemp;
targetTile = temp;
}
}
} List<Balloon> possibleTargets = targetTile.getBalloons();
target = possibleTargets.get(Math.abs(100 % possibleTargets.size()));
return target;
}
*/
//THIS METHOD IS NOT USED
/**A method that draws the tower onto the terminal
**this is only used when a terminal is used for displaying the game; if a screen is used, this method is not needed
*@param Terminal t
*/
public void draw(Terminal t){
t.moveCursor(x, y);
t.applyBackgroundColor(Terminal.Color.BLACK);
t.putCharacter(' ');
t.applyBackgroundColor(Terminal.Color.DEFAULT);
t.applyForegroundColor(Terminal.Color.DEFAULT);
}
}