Archived
1
0

-Sorted files into different packages to clean up object list

Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
Tony Grosinger 2011-09-20 14:57:18 -07:00
parent 2d5235222d
commit fbdffb5905
54 changed files with 132 additions and 51 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,18 @@ package net.grosinger.nomads;
import java.util.ArrayList;
import net.grosinger.nomads.Building.Structure;
import net.grosinger.nomads.buildings.Building;
import net.grosinger.nomads.buildings.House;
import net.grosinger.nomads.buildings.NeighborBuilding;
import net.grosinger.nomads.buildings.PoliceStation;
import net.grosinger.nomads.buildings.RepairShop;
import net.grosinger.nomads.buildings.TownHall;
import net.grosinger.nomads.buildings.UpgradeShop;
import net.grosinger.nomads.buildings.Building.Structure;
import net.grosinger.nomads.drones.Drone;
import net.grosinger.nomads.drones.DroneListItem;
import net.grosinger.nomads.drones.DroneTeam;
import net.grosinger.nomads.drones.NeighborDrone;
/**
* Tools for the Drone to use. Only place methods in here that you want the
@ -147,40 +158,33 @@ public class DroneTools {
int maxDistance = listItem.getVisibleDistance();
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) {
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);
GameObject objectHere = worldReference.getObjectAt(getX() + i, getY() + j);
if (objectHere instanceof Building) {
Building buildingHere = (Building) objectHere;
NeighborBuilding aWildNeighbor;
if (buildingHere.getType() == Structure.TOWNHALL) {
aWildNeighbor = new TownHall(buildingHere.getX(),
buildingHere.getY(),
buildingHere.getName(), buildingHere,
listItem);
aWildNeighbor = new TownHall(buildingHere.getX(), buildingHere.getY(),
buildingHere.getName(), buildingHere, listItem);
} else if (buildingHere.getType() == Structure.REPAIRSHOP) {
aWildNeighbor = new RepairShop(buildingHere.getX(),
buildingHere.getY(),
buildingHere.getName(), buildingHere,
buildingHere.getY(), buildingHere.getName(), buildingHere,
listItem);
} else if (buildingHere.getType() == Structure.UPGRADESHOP) {
aWildNeighbor = new UpgradeShop(
buildingHere.getX(), buildingHere.getY(),
buildingHere.getName(), buildingHere,
aWildNeighbor = new UpgradeShop(buildingHere.getX(),
buildingHere.getY(), buildingHere.getName(), buildingHere,
listItem);
} else if (buildingHere.getType() == Structure.POLICESTATION) {
aWildNeighbor = new PoliceStation(
buildingHere.getX(), buildingHere.getY(),
buildingHere.getName(), buildingHere,
aWildNeighbor = new PoliceStation(buildingHere.getX(),
buildingHere.getY(), buildingHere.getName(), buildingHere,
listItem);
} else {
aWildNeighbor = new NeighborBuilding(
buildingHere.getX(), buildingHere.getY(),
buildingHere.getName(), buildingHere,
aWildNeighbor = new NeighborBuilding(buildingHere.getX(),
buildingHere.getY(), buildingHere.getName(), buildingHere,
listItem);
}
@ -203,19 +207,16 @@ public class DroneTools {
int maxDistance = listItem.getVisibleDistance();
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) {
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);
GameObject objectHere = worldReference.getObjectAt(getX() + i, getY() + j);
if (objectHere instanceof Drone) {
Drone droneHere = (Drone) objectHere;
DroneListItem listItemHere = Nomads
.droneToListItem(droneHere);
NeighborDrone aWildNeighbor = new NeighborDrone(
listItemHere.getX(), listItemHere.getY(),
droneHere.getName(), droneHere.getUID());
DroneListItem listItemHere = Nomads.droneToListItem(droneHere);
NeighborDrone aWildNeighbor = new NeighborDrone(listItemHere.getX(),
listItemHere.getY(), droneHere.getName(), droneHere.getUID());
neighbors.add(aWildNeighbor);
}
}
@ -224,6 +225,30 @@ public class DroneTools {
return neighbors;
}
/**
* Retrieve a list of all MoneyPiles that are visible from this drone.
* Does not return the money pile itself, rather just a point where one
* lies.
*
* @return ArrayList of Points
*/
public ArrayList<Point> checkLumaLocator() {
// TODO - Implement LumaLocator
return null;
}
/**
* Retrieve a list of all objectives that are visible from this drone.
* Will tell if the objective belongs to this drone or not.
*
* @return ArrayList of ObjectiveReferences
*/
public ArrayList<Objective> checkObjectiveLocator() {
// TODO - Implement ObjectiveLocator
// Should not actually return an Objective
return null;
}
/**
* If your team has enough money, will create a house 1 space east of
* current location.
@ -237,8 +262,8 @@ public class DroneTools {
Point intendedPoint = new Point(getX(), getY());
findEmptyPoint(intendedPoint);
House newHouse = new House(Structure.HOUSE, intendedPoint.getX(),
intendedPoint.getY(), currentTeam);
House newHouse = new House(Structure.HOUSE, intendedPoint.getX(), intendedPoint.getY(),
currentTeam);
worldReference.placeNewBuilding(newHouse);
currentTeam.deductFromBalance(Nomads.HOUSEPRICE);
listItem.setWaiting(Nomads.CREATIONTIME);
@ -268,8 +293,7 @@ public class DroneTools {
*/
private Point findEmptyPoint(Point currentPoint) {
// Current point is where the drone is
boolean validSpace = worldReference.getObjectAt(currentPoint.getX(),
currentPoint.getY()) == null;
boolean validSpace = worldReference.getObjectAt(currentPoint.getX(), currentPoint.getY()) == null;
Point tryThis = new Point(currentPoint.getX(), currentPoint.getY());
int outX = 1;
int outY = 0;

View File

@ -10,7 +10,10 @@ import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import net.grosinger.nomads.Building.Structure;
import net.grosinger.nomads.buildings.Building;
import net.grosinger.nomads.buildings.Building.Structure;
import net.grosinger.nomads.drones.Drone;
import net.grosinger.nomads.drones.DroneTeam;
/**
* Various methods used when first setting up the game and loading everything

View File

@ -2,6 +2,7 @@ package net.grosinger.nomads;
import java.util.ArrayList;
import net.grosinger.nomads.drones.DroneListItem;
import net.grosinger.nomads.exceptions.FullInventoryException;
public class Inventory {

View File

@ -3,6 +3,10 @@ package net.grosinger.nomads;
import java.io.IOException;
import java.util.ArrayList;
import net.grosinger.nomads.drones.Drone;
import net.grosinger.nomads.drones.DroneListItem;
import net.grosinger.nomads.drones.DroneTeam;
public class Nomads {
public static World awesomeWorld;

View File

@ -2,6 +2,8 @@ package net.grosinger.nomads;
import java.util.Hashtable;
import net.grosinger.nomads.drones.DroneListItem;
public class Upgrade {
public enum UpgradeType {

View File

@ -9,6 +9,12 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import net.grosinger.nomads.buildings.Building;
import net.grosinger.nomads.buildings.House;
import net.grosinger.nomads.drones.Drone;
import net.grosinger.nomads.drones.DroneListItem;
import net.grosinger.nomads.drones.DroneTeam;
/**
* Main class where information about the world is stored
*
@ -173,10 +179,9 @@ public class World {
* GameObject to be placed
*/
public void setObjectRandom(GameObject newItem) {
// TODO - Able to go out of bounds
// Min + (int)(Math.random() * ((Max - Min) + 1))
int randX = 0 + (int) (Math.random() * ((getWorldSize() - 0) + 1));
int randY = 0 + (int) (Math.random() * ((getWorldSize() - 0) + 1));
int randX = 0 + (int) (Math.random() * ((getWorldSize() - 1 - 0) + 1));
int randY = 0 + (int) (Math.random() * ((getWorldSize() - 1 - 0) + 1));
setObjectAt(randX, randY, newItem);
}

View File

@ -1,4 +1,7 @@
package net.grosinger.nomads;
package net.grosinger.nomads.buildings;
import net.grosinger.nomads.GameObject;
import net.grosinger.nomads.drones.DroneTeam;
/*

View File

@ -1,4 +1,7 @@
package net.grosinger.nomads;
package net.grosinger.nomads.buildings;
import net.grosinger.nomads.Nomads;
import net.grosinger.nomads.drones.DroneTeam;
/**

View File

@ -1,4 +1,8 @@
package net.grosinger.nomads;
package net.grosinger.nomads.buildings;
import net.grosinger.nomads.GameObject;
import net.grosinger.nomads.Nomads;
import net.grosinger.nomads.drones.DroneListItem;
/**
* An array of NeigborBuildings will be given to a drone that is searching for

View File

@ -1,4 +1,6 @@
package net.grosinger.nomads;
package net.grosinger.nomads.buildings;
import net.grosinger.nomads.drones.DroneListItem;
/**
* A representation of a PoliceStation. Allows Drones to interact with this

View File

@ -1,4 +1,6 @@
package net.grosinger.nomads;
package net.grosinger.nomads.buildings;
import net.grosinger.nomads.drones.DroneListItem;
/**
* A representation of a RepairShop. Allows Drones to interact with this

View File

@ -1,5 +1,13 @@
package net.grosinger.nomads;
package net.grosinger.nomads.buildings;
import net.grosinger.nomads.GameObject;
import net.grosinger.nomads.Inventory;
import net.grosinger.nomads.MoneyPile;
import net.grosinger.nomads.Nomads;
import net.grosinger.nomads.Objective;
import net.grosinger.nomads.Point;
import net.grosinger.nomads.drones.DroneListItem;
import net.grosinger.nomads.drones.DroneTeam;
import net.grosinger.nomads.exceptions.BadRequestException;
import net.grosinger.nomads.exceptions.ObjectReferenceOutdatedException;

View File

@ -1,5 +1,7 @@
package net.grosinger.nomads;
package net.grosinger.nomads.buildings;
import net.grosinger.nomads.Upgrade;
import net.grosinger.nomads.drones.DroneListItem;
import net.grosinger.nomads.exceptions.InsufficientFundsException;
import net.grosinger.nomads.exceptions.InvalidUpgradeException;

View File

@ -1,6 +1,8 @@
package net.grosinger.nomads;
package net.grosinger.nomads.drones;
import net.grosinger.nomads.DroneListItem.EnumMove;
import net.grosinger.nomads.DroneTools;
import net.grosinger.nomads.GameObject;
import net.grosinger.nomads.drones.DroneListItem.EnumMove;
/**
* All drones will extend this class. Gives them access to basic set of tools

View File

@ -1,7 +1,14 @@
package net.grosinger.nomads;
package net.grosinger.nomads.drones;
import java.util.ArrayList;
import net.grosinger.nomads.DroneTools;
import net.grosinger.nomads.GameObject;
import net.grosinger.nomads.Inventory;
import net.grosinger.nomads.MoneyPile;
import net.grosinger.nomads.Nomads;
import net.grosinger.nomads.Objective;
import net.grosinger.nomads.Upgrade;
import net.grosinger.nomads.Upgrade.UpgradeType;
import net.grosinger.nomads.exceptions.FullInventoryException;

View File

@ -1,7 +1,13 @@
package net.grosinger.nomads;
package net.grosinger.nomads.drones;
import java.util.ArrayList;
import net.grosinger.nomads.GameObject;
import net.grosinger.nomads.InitializeGame;
import net.grosinger.nomads.Nomads;
import net.grosinger.nomads.Point;
import net.grosinger.nomads.buildings.House;
/**
* Contains a pointer to the first and the last DroneListItem in a particular

View File

@ -1,4 +1,6 @@
package net.grosinger.nomads;
package net.grosinger.nomads.drones;
import net.grosinger.nomads.GameObject;
/**

View File

@ -1,6 +1,7 @@
package net.grosinger.nomads;
package net.grosinger.nomads.drones;
import net.grosinger.nomads.DroneListItem.EnumMove;
import net.grosinger.nomads.DroneTools;
import net.grosinger.nomads.drones.DroneListItem.EnumMove;
/**
* Enforcer of the law. Has the ability to arrest drones that are wanted. Police