Finished Objectives
Signed-off-by: Tony Grosinger <github2@grosinger.net>
This commit is contained in:
parent
ec147dede8
commit
a0e3d07a90
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -380,15 +380,23 @@ public class DroneListItem {
|
||||
// Check to see if there is a MoneyPile or Objective there
|
||||
GameObject objectHere = Nomads.awesomeWorld.getObjectAt(getX() + amountE, getY() + amountN);
|
||||
|
||||
if (inventory.size() < cargoSpace) {
|
||||
if (objectHere instanceof MoneyPile) {
|
||||
inventory.add(objectHere);
|
||||
} else if (objectHere instanceof Objective) {
|
||||
// TODO - Check to see that this drone is the owner of that
|
||||
// Objective
|
||||
if (objectHere != null) {
|
||||
if (inventory.size() < cargoSpace) {
|
||||
if (objectHere instanceof MoneyPile) {
|
||||
inventory.add(objectHere);
|
||||
} else if (objectHere instanceof Objective) {
|
||||
String objUID = ((Objective) objectHere).getUID();
|
||||
String droneUID = current.getUID();
|
||||
|
||||
if (objUID.equals(droneUID)) {
|
||||
inventory.add(objectHere);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// TODO - Inventory is full, do not allow move
|
||||
}
|
||||
|
||||
// Make the move
|
||||
|
@ -44,6 +44,9 @@ public class Nomads {
|
||||
*/
|
||||
public static final int MONEYPILES = 30;
|
||||
|
||||
public static final int MAXOBJECTIVEBOUNTY = 30;
|
||||
public static final int MINOBJECTIVEBOUNTY = 10;
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (DEBUGSTATUS)
|
||||
System.out.println("Game initialization beginning...");
|
||||
|
@ -16,8 +16,13 @@ public class TownHall extends Building {
|
||||
team.increaseBalance(value);
|
||||
Nomads.awesomeWorld.generateMoneyPile();
|
||||
} else if (currentObject instanceof Objective) {
|
||||
// TODO - Implement turning in objective
|
||||
team.increaseBalance(((Objective) currentObject).getBounty());
|
||||
}
|
||||
inventory.remove(currentObject);
|
||||
}
|
||||
}
|
||||
|
||||
public Point requestNewObjective(String UID){
|
||||
return Nomads.awesomeWorld.generateObjective(UID);
|
||||
}
|
||||
}
|
||||
|
@ -114,6 +114,8 @@ public class World {
|
||||
*/
|
||||
public void setObjectAt(int x, int y, GameObject newItem) {
|
||||
theWorld[x][y] = newItem;
|
||||
// TODO - Make sure this spot is free.
|
||||
// If it is not, then move somewhere close by
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,6 +230,33 @@ public class World {
|
||||
setObjectRandom(newPile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a newObjective for the given UID. Returns a point that is randomly
|
||||
* close to the actual location of the Objective
|
||||
*
|
||||
* @param UID
|
||||
* - The UID of the Drone that is allowed to pick it up.
|
||||
* @return - <code>Point</code> - Within 20x20 of the Objective.
|
||||
*/
|
||||
public Point generateObjective(String UID) {
|
||||
// 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 varY = -10 + (int) (Math.random() * ((10 - -10) + 1));
|
||||
int varX = -10 + (int) (Math.random() * ((10 - -10) + 1));
|
||||
|
||||
int bounty = Nomads.MINOBJECTIVEBOUNTY + (int) (Math.random() * ((Nomads.MAXOBJECTIVEBOUNTY - Nomads.MINOBJECTIVEBOUNTY) + 1));
|
||||
|
||||
Objective newObjective = new Objective(bounty, UID);
|
||||
setObjectAt(randX, randY, newObjective);
|
||||
|
||||
//Create a point to return that is somewhere nearby the actual location
|
||||
Point pointCloseBy = new Point(randX+varX, randY+varY);
|
||||
|
||||
return pointCloseBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs an HTML file showing the world
|
||||
*/
|
||||
|
Reference in New Issue
Block a user