- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTargetUnit.java
More file actions
Latest commit
68 lines (62 loc) · 1.77 KB
/
Copy pathTargetUnit.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
importjava.util.ArrayList;
importjava.util.HashSet;
importjava.util.TreeSet;
importbc.*;
/*
data structure for keeping track of enemy units
*/
publicclassTargetUnit {
intID;
longhealth;
intdamageDealingPower;
intpriority;
MapLocationmyLoc;
UnitTypetype;
ArrayList<Tile> tilesWhichHitMe;
longrange;
longdefense;
doublesnipePriority;
longsnipeDamageToDo;
InfoManagerinfoMan;
publicTargetUnit(Unitunit, InfoManagerim){
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 = newArrayList<Tile>();
switch(type){ // TWEAK: maybe
caseRocket: priority = (myLoc.getPlanet() == Planet.Earth ? 7 : 1); break;
caseFactory: priority = 6; break;
caseMage: priority = 5; break;
caseHealer: priority = 4; break;
caseKnight: priority = 3; break;
caseRanger: priority = 2; break;
caseWorker: priority = 1;
}
}
// TWEAK: not exactly sure what, but maybe we want to? also see the priority list above
publicvoidupdateSnipePriority(MapLocationswarmLoc){
snipePriority = priority + 1 + swarmLoc.distanceSquaredTo(myLoc) / 25.0;
snipeDamageToDo = health;
for(TargetUnittu: infoMan.getTargetUnits(myLoc, 2, false)){
if(tu.ID != ID){
snipePriority += tu.priority;
if(tu.health > snipeDamageToDo)
snipeDamageToDo = tu.health;
}
}
}
publicbooleanequals(Objecto){
if(!(oinstanceofTargetUnit))
returnfalse;
returnID == ((TargetUnit)o).ID;
}
}