-Started to add distanceFromPoint to drone tools
-Continued implementation of move in Police Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
parent
9190e7c306
commit
589eb0f8e7
Binary file not shown.
Binary file not shown.
@ -387,4 +387,17 @@ public class DroneTools {
|
||||
public int getTeamBalance() {
|
||||
return currentTeam.getBalance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates and returns the distance of the drone from a provided point.
|
||||
* Number is rounded up to nearest whole number >= actual distance.
|
||||
*
|
||||
* @param p
|
||||
* Point to find distance to
|
||||
* @return <code>int</code>
|
||||
*/
|
||||
public int distanceFromPoint(Point p) {
|
||||
return 1;
|
||||
// TODO - Implement distanceFromePoint
|
||||
}
|
||||
}
|
||||
|
@ -77,8 +77,12 @@ public class Police implements Drone {
|
||||
for (NeighborDrone aDrone : tools.checkRadar()) {
|
||||
if (aDrone.getUID().equals(UIDofDroneIAmFollowing)) {
|
||||
// If I am within 1 space of it, attack
|
||||
// TODO
|
||||
// Else move towards it
|
||||
Point droneBeingFollowed = new Point(aDrone.getX(), aDrone.getY());
|
||||
if (tools.distanceFromPoint(droneBeingFollowed) <= 1) {
|
||||
return EnumMove.Attack;
|
||||
} else {
|
||||
goToPoint(droneBeingFollowed);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (iAmGoingToGiveBackup != null) {
|
||||
|
Reference in New Issue
Block a user