forked from ShinyLuxray/LastStandDefence
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTower.java~
More file actions
168 lines (146 loc) · 3.83 KB
/
Tower.java~
File metadata and controls
168 lines (146 loc) · 3.83 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import java.lang.Math;
public class Tower
{
int id;
int period;
int damage;
int range;
int upperiod = 0,updamage = 0,uprange = 0;
final Position pos;
public Tower (int initializeid, Position p)
{
this.pos = p;
this.id = initializeid;
System.out.println("This tower has ID: " + id);
//hardcode shit
//if (id == 0)
//{
// damage = ...; ...
//}
if(id == 1) // The cannon; slow-firing with low range, but relatively nice damage
{
period = 1000;
damage = 20;
range = 5;
}
else if(id == 2) // The laser; this piece of shit doesn't really have any redeeming qualities
{
period = 750;
damage = 10;
range = 7;
}
else if(id == 3) // The rocket; this thing is OP as fuck because of its long range
{
period = 1000;
damage = 15;
range = 15;
}
else if(id == 4) // The taser; basically just RoF
{
period = 200;
damage = 10;
range = 3;
}
}
public Position getPos()
{
return pos;
}
public int getRange()
{
return range;
}
public int getPower()
{
return damage;
}
public int getPeriod()
{
return period;
}
public int getType()
{
return id;
}
public int getValue()
{
int moneyz = 100+id*100,price = 100;
for(int a = 0;a<5;a++)
{
price*=2;
if(uprange>a)
moneyz += price;
if(updamage>a)
moneyz += price;
if(upperiod>a)
moneyz += price;
}
return moneyz;
}
public boolean upgrade (String statToUpgrade)
{
if(statToUpgrade.toLowerCase().equals("period")||statToUpgrade.toLowerCase().equals("rate"))
{
if(LSD.money<(int)Math.pow(2,upperiod+1))
return false;
LSD.money-=(int)Math.pow(2,upperiod+1);
upperiod++;
period=(period*3)/4;
return true;
}
else if (statToUpgrade.toLowerCase().equals("range"))
{
if(LSD.money<(int)Math.pow(2,uprange+1))
return false;
LSD.money-=(int)Math.pow(2,uprange+1);
uprange++;
range++;
return true;
}
else if(statToUpgrade.toLowerCase().equals("damage"))
{
if(LSD.money<(int)Math.pow(2,updamage+1))
return false;
LSD.money-=(int)Math.pow(2,updamage+1);
updamage++;
damage++;
return true;
}
else
return false;
}
protected void fire()
{
int atkindex = -1;
int maxPathID = -1;
for (int i = 0; i < LSD.wave.size(); i++)
{
if (LSD.wave.get(i).inRange(Tower.this))
{
if (LSD.wave.get(i).getPathId() > maxPathID)
{
maxPathID = LSD.wave.get(i).getPathId();
atkindex = i;
System.out.println ("Checking");
}
}
}
if(atkindex!=-1)
{
System.out.println ("Attacking");
try
{
if(LSD.wave.get(atkindex).inRange(Tower.this)&&LSD.wave.get(atkindex).hit(damage))
{
System.out.println("Removed: " + atkindex);
LSD.wave.remove(atkindex);
LSD.kills++;
if(LSD.wave.size()==0)
LSD.waveDone = true;
}
}
catch(Exception hotfix)
{}
}
}
}