-Continued building move method in Police
Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
parent
2a764b5073
commit
9190e7c306
Binary file not shown.
@ -70,13 +70,26 @@ public class Police implements Drone {
|
|||||||
System.out.println("Policeman about to move");
|
System.out.println("Policeman about to move");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(UIDofDroneIAmFollowing != null){
|
if (UIDofDroneIAmFollowing != null) {
|
||||||
//TODO
|
// Look to see if I can see that drone still, if I can then go
|
||||||
}else if (iAmGoingToGiveBackup != null) {
|
// towards it.
|
||||||
// If I am not at this point already, go there
|
|
||||||
|
|
||||||
// If I am at that point, unset the variable and start looking for
|
for (NeighborDrone aDrone : tools.checkRadar()) {
|
||||||
// people
|
if (aDrone.getUID().equals(UIDofDroneIAmFollowing)) {
|
||||||
|
// If I am within 1 space of it, attack
|
||||||
|
// TODO
|
||||||
|
// Else move towards it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (iAmGoingToGiveBackup != null) {
|
||||||
|
// If I am not at this point already, go there
|
||||||
|
if (!atPoint(iAmGoingToGiveBackup)) {
|
||||||
|
return goToPoint(iAmGoingToGiveBackup);
|
||||||
|
} else {
|
||||||
|
// If I am at that point, unset the variable and start looking
|
||||||
|
// for people
|
||||||
|
iAmGoingToGiveBackup = null;
|
||||||
|
}
|
||||||
} else if (backupRequestedHere != null) {
|
} else if (backupRequestedHere != null) {
|
||||||
// Another policeman needs backup, go there
|
// Another policeman needs backup, go there
|
||||||
EnumMove returnThis = goToPoint(backupRequestedHere);
|
EnumMove returnThis = goToPoint(backupRequestedHere);
|
||||||
@ -132,7 +145,7 @@ public class Police implements Drone {
|
|||||||
private EnumMove pickRandomDirection() {
|
private EnumMove pickRandomDirection() {
|
||||||
// Min + (int)(Math.random() * ((Max - Min) + 1))
|
// Min + (int)(Math.random() * ((Max - Min) + 1))
|
||||||
int rand = 1 + (int) (Math.random() * ((4 - 1) + 1));
|
int rand = 1 + (int) (Math.random() * ((4 - 1) + 1));
|
||||||
|
|
||||||
switch (rand) {
|
switch (rand) {
|
||||||
case (1): {
|
case (1): {
|
||||||
return EnumMove.North;
|
return EnumMove.North;
|
||||||
@ -192,4 +205,16 @@ public class Police implements Drone {
|
|||||||
return EnumMove.NoMove;
|
return EnumMove.NoMove;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decides if this police drone is at the point that is passed.
|
||||||
|
*
|
||||||
|
* @param here
|
||||||
|
* A point to test for
|
||||||
|
* @return <code>Boolean</code>
|
||||||
|
*/
|
||||||
|
private Boolean atPoint(Point here) {
|
||||||
|
// TODO - Implement atPoint
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user