Archived
1
0

-Refactored Neighbor to NeighborDrone

-Created NeighborBuilding

Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
Tony Grosinger 2011-09-10 21:57:45 -07:00
parent 564c97c8b9
commit 89a6f1e559
12 changed files with 114 additions and 13 deletions

Binary file not shown.

Binary file not shown.

View File

@ -43,7 +43,7 @@ public interface Drone extends GameObject {
*
* @return <code>Neighbor</code>;
*/
public Neighbor steal();
public NeighborDrone steal();
/**
* Asks for which drone should be attacked. Will be called whenever the Move
@ -51,7 +51,7 @@ public interface Drone extends GameObject {
*
* @return <code>Neighbor</code>
*/
public Neighbor attack();
public NeighborDrone attack();
/**
* Asks what the drone would like to upgrade. Will be called whenever the Move

View File

@ -32,7 +32,8 @@ public class DroneListItem {
// Statistics about this robot
private int visibleDistance;
private int visibleDistance; // Distance that this drone can see buildings
// and other drones
private int lumaLocatorDistance;
private int objectLocatorDistance;
private int reliability;
@ -400,7 +401,7 @@ public class DroneListItem {
* Finds who the drone wants to attack and attempts to perform attack.
*/
private void doAttack() {
Neighbor victimNeighbor = current.attack();
NeighborDrone victimNeighbor = current.attack();
if (victimNeighbor == null) {
// Seems they did something wrong. Turn wasted.
@ -440,7 +441,7 @@ public class DroneListItem {
* Finds who the drone wants to steal from and attempts to perform steal.
*/
private void doSteal() {
Neighbor victimNeighbor = current.steal();
NeighborDrone victimNeighbor = current.steal();
if (victimNeighbor == null) {
// Seems they did something wrong. Turn wasted.

View File

@ -14,6 +14,7 @@ public class DroneTools {
private DroneListItem listItem;
private DroneTeam currentTeam;
private World worldReference;
private Point townCenter;
private int worldSize;
public DroneTools(Drone aDrone, DroneListItem droneParent, World theWorld) {
@ -122,14 +123,31 @@ public class DroneTools {
return worldReference.inSafeZone(getX(), getY(), listItem);
}
/**
* Return the location of the center of the main town. Buildings are located
* on the corners of this point.
*
* @return <code>Point</code>
*/
public Point getTownCenter() {
if (townCenter == null) {
townCenter = new Point(30, 50);
}
return townCenter;
}
public ArrayList<Building> checkBuildings() {
return worldReference.buildingsInRange(getX(), getY(), listItem.getVisibleDistance());
}
/**
* Retrieve a list of all Drones that are visible within your sight range.
* (Sight range can be upgraded)
*
* @return ArrayList of Neighbors
*/
public ArrayList<Neighbor> checkRadar() {
ArrayList<Neighbor> neighbors = new ArrayList<Neighbor>();
public ArrayList<NeighborDrone> checkRadar() {
ArrayList<NeighborDrone> neighbors = new ArrayList<NeighborDrone>();
int maxDistance = listItem.getVisibleDistance();
for (int i = maxDistance * -1; i <= maxDistance; i++) {
for (int j = maxDistance * -1; j <= maxDistance; j++) {
@ -143,7 +161,7 @@ public class DroneTools {
Drone droneHere = (Drone) objectHere;
DroneListItem listItemHere = Nomads
.droneToListItem(droneHere);
Neighbor aWildNeighbor = new Neighbor(
NeighborDrone aWildNeighbor = new NeighborDrone(
listItemHere.getX(), listItemHere.getY(),
droneHere.getName(), droneHere.getUID());
neighbors.add(aWildNeighbor);

View File

@ -0,0 +1,82 @@
package net.grosinger.nomads;
import net.grosinger.nomads.Building.Structure;
/**
* An array of NeigborBuildings will be given to a drone that is searching for
* the buildings it is near. This is typically done from the town center.
*/
public class NeighborBuilding implements GameObject {
private String name;
private int x;
private int y;
private String UID;
private Building building;
/**
* Class Constructor
*
* @param x
* - X location of the Building
* @param y
* - Y location of the Building
* @param name
* - Name of the Building
*/
public NeighborBuilding(int x, int y, String name, String UID,
Building building) {
this.x = x;
this.y = y;
this.name = name;
this.UID = UID;
this.building = building;
}
@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 type of building that this is
*
* @return <code>Structure</code>
*/
public Structure getType() {
return building.getType();
}
/**
* Retrieve UID of this Neighbor
*
* @return <code>String</code> - UID
*/
public String getUID() {
return UID;
}
@Override
public void setName(String newName) {
name = newName;
}
}

View File

@ -1,9 +1,9 @@
package net.grosinger.nomads;
/**
* An array of Neighbors will be given to a drone that is using it's radar
* An array of NeighborDrones will be given to a drone that is using it's radar
*/
public class Neighbor implements GameObject {
public class NeighborDrone implements GameObject {
private String name;
private int x;
@ -20,7 +20,7 @@ public class Neighbor implements GameObject {
* @param name
* - Name of the Drone
*/
public Neighbor(int x, int y, String name, String UID) {
public NeighborDrone(int x, int y, String name, String UID) {
this.x = x;
this.y = y;
this.name = name;

View File

@ -66,13 +66,13 @@ public class Police implements Drone {
}
@Override
public Neighbor steal() {
public NeighborDrone steal() {
// This method is not used by the police drones
return null;
}
@Override
public Neighbor attack() {
public NeighborDrone attack() {
// When attacked, a police drone will automatically retaliate, dealing
// 2x the damage that was done to itself.
// TODO - Implement Police Attack