forked from ShinyLuxray/LastStandDefence
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemy.java
More file actions
121 lines (103 loc) · 2.58 KB
/
Enemy.java
File metadata and controls
121 lines (103 loc) · 2.58 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
/**
* A class for enemy spawns.
*/
public class Enemy
{
private Position place;
private int totalHp;
private int currentHp;
private int pathId;
private int type; //not used yet?
public Enemy (int hp)
{
totalHp = hp;
currentHp = hp;
pathId = 0;
place = LSD.path.get(0);
}
public Position getPos()
{
return place;
}
public void setPos(Position pos)
{
place = pos;
}
public int getPathId()
{
return pathId;
}
public int getTotalHp()
{
return totalHp;
}
public int getCurrentHp()
{
return currentHp;
}
public void advance()
{
//System.out.println("Advance invoked");
int posIndex = 0;
for(int i = 0; i < LSD.path.size(); i++)
{
if(LSD.path.get(i).equals(place))
{
//System.out.println("Enemy is located at: " + LSD.path.get(i));
//System.out.println("Moving enemy to: " + LSD.path.get(i+1));
place = new Position(LSD.path.get(i + 1));
break;
}
}
}
/**
* run it when an enemy is attacked
* also adds moniez here for simplicity's sake
* @param power the damage that will be done
* @returns whether the enemy is dead or not
*/
public boolean hit(int power)
{
// System.out.println("Ouch.");
// System.out.println("My current HP is: " + currentHp);
// currentHp -= power;
// System.out.println("My HP Went down to: " + currentHp);
currentHp -= power;
//System.out.println ("Damaged for: " + power);
//LSD.aBoard.drawHp();
if(currentHp<1)
{
//System.out.println ("Am dead");
if (totalHp < 60)
{
LSD.money += (totalHp);
}
else
if (totalHp < 250)
{
LSD.money += (30+totalHp/4);
}
else
if (totalHp < 500)
{
LSD.money += (100+totalHp/8);
}
else
{
LSD.money += (100+LSD.waves/2);
}
return true;
}
return false;
}
public boolean inRange(Tower check)
{
if(place.distance(check.getPos())<=check.getRange())
{
//System.out.println("OH SHIT I'M IN RANGE");
return true;
}
//System.out.println("HAHA FUCKERS I'M NOT IN RANGE");
return false;
}
}