-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTargetUnit.java
More file actions
68 lines (62 loc) · 1.77 KB
/
TargetUnit.java
File metadata and controls
68 lines (62 loc) · 1.77 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
import java.util.ArrayList;
import java.util.HashSet;
import java.util.TreeSet;
import bc.*;
/*
data structure for keeping track of enemy units
*/
public class TargetUnit {
int ID;
long health;
int damageDealingPower;
int priority;
MapLocation myLoc;
UnitType type;
ArrayList<Tile> tilesWhichHitMe;
long range;
long defense;
double snipePriority;
long snipeDamageToDo;
InfoManager infoMan;
public TargetUnit(Unit unit, InfoManager im){
infoMan = im;
ID = unit.id();
type = unit.unitType();
health = unit.health();
myLoc = unit.location().mapLocation();
defense = type == UnitType.Knight ? unit.knightDefense() : 0;
damageDealingPower = 0;
range = 0;
if(unit.unitType() != UnitType.Factory && unit.unitType() != UnitType.Rocket){
damageDealingPower = unit.damage();
range = unit.attackRange();
}
tilesWhichHitMe = new ArrayList<Tile>();
switch(type){ // TWEAK: maybe
case Rocket: priority = (myLoc.getPlanet() == Planet.Earth ? 7 : 1); break;
case Factory: priority = 6; break;
case Mage: priority = 5; break;
case Healer: priority = 4; break;
case Knight: priority = 3; break;
case Ranger: priority = 2; break;
case Worker: priority = 1;
}
}
// TWEAK: not exactly sure what, but maybe we want to? also see the priority list above
public void updateSnipePriority(MapLocation swarmLoc){
snipePriority = priority + 1 + swarmLoc.distanceSquaredTo(myLoc) / 25.0;
snipeDamageToDo = health;
for(TargetUnit tu: infoMan.getTargetUnits(myLoc, 2, false)){
if(tu.ID != ID){
snipePriority += tu.priority;
if(tu.health > snipeDamageToDo)
snipeDamageToDo = tu.health;
}
}
}
public boolean equals(Object o){
if(!(o instanceof TargetUnit))
return false;
return ID == ((TargetUnit)o).ID;
}
}