Skip to content
Permalink
af42b10cc5
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
93 lines (88 sloc) 1.72 KB
public class MinionMock {
private int type, x, y, speed, visits, health, attackDamage;
private boolean alive;
private MapTowerDefense map;
public MinionMock(MinionTypes type, MapTowerDefense map) {
this.map = map;
int[] unhashed = map.getGui().hash(map.getNodes()[0][0], map.getNodes()[0][1]);
x = unhashed[0];
y = unhashed[1];
health = type.getHealth();
attackDamage = type.getAttackDamage();
speed = type.getMovementSpeed();
visits = 1;
alive = true;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getType() {
return 0; //TODO
}
public int findDirection() {
if (visits == map.getNum()) {
// CALL TO MAKE NEXUS LOSE HEALTH
return -1;
} else {
int xGoal = map.getNodes()[visits][0];
int yGoal = map.getNodes()[visits][1];
int[] Goals = map.getGui().hash(xGoal, yGoal);
xGoal = Goals[0];
yGoal = Goals[1];
if (x == xGoal) {
if (y == yGoal) {
visits++;
return findDirection();
}
if (yGoal > y) {
// MOVE DOWN
return 2;
} else {
return 0;
}
} else {
if (x > xGoal) {
return 3;
} else {
return 1;
}
}
}
}
public boolean go() {
int direction = findDirection();
if (direction == -1) {
alive = false;
return map.getTF().getTowerArray()[0].takeDamage();
}
if (direction == 0) {
y-=speed;
}
if (direction == 1) {
x+=speed;
}
if (direction == 2) {
y+=speed;
}
if (direction == 3) {
x-=speed;
}
return false;
}
public boolean isAlive() {
return alive;
}
public int getHealth() {
return health;
}
public void minionTakeDamage() {
int dam = map.getTF().assignTotalDamage(x, y);
health-=dam;
if (health <= 0) {
alive = false;
}
}
}