Archived
1
0

-NeighborBuilding is now Drone specific.

Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
Tony Grosinger 2011-09-15 13:52:08 -07:00
parent 77c93d6c2c
commit 8d6840ac87
12 changed files with 40 additions and 23 deletions

View File

@ -160,23 +160,28 @@ public class DroneTools {
if (buildingHere.getType() == Structure.TOWNHALL) { if (buildingHere.getType() == Structure.TOWNHALL) {
aWildNeighbor = new TownHall(buildingHere.getX(), aWildNeighbor = new TownHall(buildingHere.getX(),
buildingHere.getY(), buildingHere.getY(),
buildingHere.getName(), buildingHere); buildingHere.getName(), buildingHere,
listItem);
} else if (buildingHere.getType() == Structure.REPAIRSHOP) { } else if (buildingHere.getType() == Structure.REPAIRSHOP) {
aWildNeighbor = new RepairShop(buildingHere.getX(), aWildNeighbor = new RepairShop(buildingHere.getX(),
buildingHere.getY(), buildingHere.getY(),
buildingHere.getName(), buildingHere); buildingHere.getName(), buildingHere,
listItem);
} else if (buildingHere.getType() == Structure.UPGRADESHOP) { } else if (buildingHere.getType() == Structure.UPGRADESHOP) {
aWildNeighbor = new UpgradeShop( aWildNeighbor = new UpgradeShop(
buildingHere.getX(), buildingHere.getY(), buildingHere.getX(), buildingHere.getY(),
buildingHere.getName(), buildingHere); buildingHere.getName(), buildingHere,
listItem);
} else if (buildingHere.getType() == Structure.POLICESTATION) { } else if (buildingHere.getType() == Structure.POLICESTATION) {
aWildNeighbor = new PoliceStation( aWildNeighbor = new PoliceStation(
buildingHere.getX(), buildingHere.getY(), buildingHere.getX(), buildingHere.getY(),
buildingHere.getName(), buildingHere); buildingHere.getName(), buildingHere,
listItem);
} else { } else {
aWildNeighbor = new NeighborBuilding( aWildNeighbor = new NeighborBuilding(
buildingHere.getX(), buildingHere.getY(), buildingHere.getX(), buildingHere.getY(),
buildingHere.getName(), buildingHere); buildingHere.getName(), buildingHere,
listItem);
} }
neighbors.add(aWildNeighbor); neighbors.add(aWildNeighbor);

View File

@ -11,6 +11,7 @@ public class NeighborBuilding implements GameObject {
private int x; private int x;
private int y; private int y;
private Building building; private Building building;
private DroneListItem drone;
/** /**
* Class Constructor * Class Constructor
@ -22,11 +23,12 @@ public class NeighborBuilding implements GameObject {
* @param name * @param name
* - Name of the Building * - Name of the Building
*/ */
public NeighborBuilding(int x, int y, String name, Building building) { public NeighborBuilding(int x, int y, String name, Building building, DroneListItem drone) {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.name = name; this.name = name;
this.building = building; this.building = building;
this.drone = drone;
turnCreated = Nomads.turn; turnCreated = Nomads.turn;
} }

View File

@ -6,8 +6,9 @@ package net.grosinger.nomads;
*/ */
public class PoliceStation extends NeighborBuilding { public class PoliceStation extends NeighborBuilding {
public PoliceStation(int x, int y, String name, Building building) { public PoliceStation(int x, int y, String name, Building building,
super(x, y, name, building); DroneListItem drone) {
super(x, y, name, building, drone);
} }
} }

View File

@ -6,8 +6,9 @@ package net.grosinger.nomads;
*/ */
public class RepairShop extends NeighborBuilding { public class RepairShop extends NeighborBuilding {
public RepairShop(int x, int y, String name, Building building) { public RepairShop(int x, int y, String name, Building building,
super(x, y, name, building); DroneListItem drone) {
super(x, y, name, building, drone);
} }
} }

View File

@ -9,8 +9,9 @@ public class TownHall extends NeighborBuilding {
// TODO - Rewrite class to make more accessible to Drones // TODO - Rewrite class to make more accessible to Drones
public TownHall(int x, int y, String name, Building building) { public TownHall(int x, int y, String name, Building building,
super(x, y, name, building); DroneListItem drone) {
super(x, y, name, building, drone);
} }
/** /**
@ -21,16 +22,21 @@ public class TownHall extends NeighborBuilding {
* @param team * @param team
*/ */
public void cashInventory(ArrayList<GameObject> inventory, DroneTeam team) { public void cashInventory(ArrayList<GameObject> inventory, DroneTeam team) {
while (!inventory.isEmpty()) { if (verifyObjectValidity()) {
GameObject currentObject = inventory.get(0); while (!inventory.isEmpty()) {
if (currentObject instanceof MoneyPile) { GameObject currentObject = inventory.get(0);
int value = ((MoneyPile) currentObject).getValue(); if (currentObject instanceof MoneyPile) {
team.increaseBalance(value); int value = ((MoneyPile) currentObject).getValue();
Nomads.awesomeWorld.generateMoneyPile(); team.increaseBalance(value);
} else if (currentObject instanceof Objective) { Nomads.awesomeWorld.generateMoneyPile();
team.increaseBalance(((Objective) currentObject).getBounty()); } else if (currentObject instanceof Objective) {
team.increaseBalance(((Objective) currentObject)
.getBounty());
}
inventory.remove(currentObject);
} }
inventory.remove(currentObject); } else {
// Object not valid, do Nothing
} }
} }
@ -46,6 +52,7 @@ public class TownHall extends NeighborBuilding {
if (verifyObjectValidity()) { if (verifyObjectValidity()) {
return Nomads.awesomeWorld.generateObjective(UID); return Nomads.awesomeWorld.generateObjective(UID);
} else { } else {
// Object not valid, do nothing
return null; return null;
} }
} }

View File

@ -6,8 +6,9 @@ package net.grosinger.nomads;
*/ */
public class UpgradeShop extends NeighborBuilding { public class UpgradeShop extends NeighborBuilding {
public UpgradeShop(int x, int y, String name, Building building) { public UpgradeShop(int x, int y, String name, Building building,
super(x, y, name, building); DroneListItem drone) {
super(x, y, name, building, drone);
} }
} }