-Created NeighborObjective Class to reference an objective on the map
-Implemented discovery of Objectives nearyby Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
parent
96a2b57904
commit
8b0ec5fcc0
Binary file not shown.
BIN
bin/net/grosinger/nomads/NeighborObjective.class
Normal file
BIN
bin/net/grosinger/nomads/NeighborObjective.class
Normal file
Binary file not shown.
@ -243,7 +243,6 @@ public class DroneTools {
|
||||
} else if (i != 0 && j != 0) {
|
||||
GameObject objectHere = worldReference.getObjectAt(getX() + i, getY() + j);
|
||||
if (objectHere instanceof MoneyPile) {
|
||||
MoneyPile pile = (MoneyPile) objectHere;
|
||||
Point location = new Point(getX() + i, getY() + j);
|
||||
neighbors.add(location);
|
||||
}
|
||||
@ -259,10 +258,28 @@ public class DroneTools {
|
||||
*
|
||||
* @return ArrayList of ObjectiveReferences
|
||||
*/
|
||||
public ArrayList<Objective> checkObjectiveLocator() {
|
||||
// TODO - Implement ObjectiveLocator
|
||||
// Should not actually return an Objective
|
||||
return null;
|
||||
public ArrayList<NeighborObjective> checkObjectiveLocator() {
|
||||
ArrayList<NeighborObjective> neighbors = new ArrayList<NeighborObjective>();
|
||||
int maxDistance = listItem.getObjectLocatorDistance();
|
||||
for (int i = maxDistance * -1; i <= maxDistance; i++) {
|
||||
for (int j = maxDistance * -1; j <= maxDistance; j++) {
|
||||
if (getX() + i >= worldSize - 1 || getX() + i < 0 || getY() + j >= worldSize - 1
|
||||
|| getY() + j < 0) {
|
||||
|
||||
} else if (i != 0 && j != 0) {
|
||||
GameObject objectHere = worldReference.getObjectAt(getX() + i, getY() + j);
|
||||
if (objectHere instanceof Objective) {
|
||||
Objective objectiveHere = (Objective) objectHere;
|
||||
if (objectiveHere.getUID().equals(referredDrone.getUID())) {
|
||||
NeighborObjective reference = new NeighborObjective(getX() + i, getY()
|
||||
+ j, objectiveHere);
|
||||
neighbors.add(reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
/**
|
||||
|
53
src/net/grosinger/nomads/NeighborObjective.java
Normal file
53
src/net/grosinger/nomads/NeighborObjective.java
Normal file
@ -0,0 +1,53 @@
|
||||
package net.grosinger.nomads;
|
||||
|
||||
public class NeighborObjective implements GameObject {
|
||||
|
||||
private String name;
|
||||
int x;
|
||||
int y;
|
||||
Objective reference;
|
||||
|
||||
public NeighborObjective(int x, int y, Objective obj) {
|
||||
reference = obj;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve x location
|
||||
*
|
||||
* @return <code>int</code> - x Location
|
||||
*/
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve y location
|
||||
*
|
||||
* @return <code>int</code> - y Location
|
||||
*/
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve bounty of this Objective
|
||||
*
|
||||
* @return <code>int</code>
|
||||
*/
|
||||
public int getBounty() {
|
||||
return reference.getBounty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String newName) {
|
||||
name = newName;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user