-Fixed initialization
-Added mapping for MoneyPiles and Objectives Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
parent
47ddadc865
commit
aab755aaef
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -29,8 +29,7 @@ public class InitializeGame {
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public static void initializeDrones() throws ClassNotFoundException,
|
||||
IOException {
|
||||
public static void initializeDrones() throws ClassNotFoundException, IOException {
|
||||
if (Nomads.DEBUGSTATUS)
|
||||
System.out.println("Loading the drones into world...");
|
||||
/*
|
||||
@ -53,11 +52,10 @@ public class InitializeGame {
|
||||
if (Nomads.DEBUGSTATUS)
|
||||
System.out.println("Loading " + filename);
|
||||
|
||||
File file = new File(System.getProperty("user.dir") + "/drones/"
|
||||
+ filename);
|
||||
File file = new File(System.getProperty("user.dir") + "/drones/" + filename);
|
||||
|
||||
URLClassLoader clazzLoader = URLClassLoader
|
||||
.newInstance(new URL[] { file.toURI().toURL() });
|
||||
URLClassLoader clazzLoader = URLClassLoader.newInstance(new URL[] { file.toURI()
|
||||
.toURL() });
|
||||
// System.class.getClassLoader()
|
||||
|
||||
JarFile jarFile = new JarFile(file);
|
||||
@ -68,8 +66,8 @@ public class InitializeGame {
|
||||
if (element.getName().endsWith(className + ".class")) {
|
||||
try {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class c = clazzLoader.loadClass(element.getName()
|
||||
.replaceAll(".class", "").replaceAll("/", "."));
|
||||
Class c = clazzLoader.loadClass(element.getName().replaceAll(".class", "")
|
||||
.replaceAll("/", "."));
|
||||
|
||||
// Create new GameObject
|
||||
GameObject newGameObject = (GameObject) c.newInstance();
|
||||
@ -151,8 +149,7 @@ public class InitializeGame {
|
||||
|
||||
Building townHall = new Building(Structure.TOWNHALL, 30, 40, null);
|
||||
Building upgradeShop = new Building(Structure.UPGRADESHOP, 30, 60, null);
|
||||
Building policeStation = new Building(Structure.POLICESTATION, 50, 40,
|
||||
null);
|
||||
Building policeStation = new Building(Structure.POLICESTATION, 50, 40, null);
|
||||
Building RepairShop = new Building(Structure.REPAIRSHOP, 50, 60, null);
|
||||
|
||||
if (Nomads.DEBUGSTATUS)
|
||||
@ -170,10 +167,10 @@ public class InitializeGame {
|
||||
/**
|
||||
* Generate the money piles and place them on the map
|
||||
*/
|
||||
public static void initializeMoneyPiles() {
|
||||
public static void initializeMoneyPiles(World awesomeWorld) {
|
||||
for (int i = 0; i < Nomads.MONEYPILES; i++) {
|
||||
MoneyPile newPile = new MoneyPile();
|
||||
Nomads.awesomeWorld.setObjectRandom(newPile);
|
||||
awesomeWorld.setObjectRandom(newPile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,8 +80,14 @@ public class Nomads {
|
||||
|
||||
// Generate and place all required buildings into world
|
||||
if (DEBUGSTATUS)
|
||||
System.out.println("Initializing and placing buildings");
|
||||
InitializeGame.initializeBuildngs(awesomeWorld);
|
||||
|
||||
// Generate and place MoneyPiles
|
||||
if (DEBUGSTATUS)
|
||||
System.out.println("Initializing and placing MoneyPiles");
|
||||
InitializeGame.initializeMoneyPiles(awesomeWorld);
|
||||
|
||||
// Check to make sure allTeams has been set up properly
|
||||
if (allTeams == null) {
|
||||
// Do something awesome
|
||||
|
@ -173,6 +173,7 @@ 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));
|
||||
@ -370,13 +371,15 @@ public class World {
|
||||
g2d.setColor(Color.black);
|
||||
g2d.fillRect(j * 10, i * 10, 10, 10);
|
||||
} else if (objectHere instanceof MoneyPile) {
|
||||
// TODO - Implement mapping of MoneyPiles
|
||||
// Should be black since they are world owned but a
|
||||
// different shape than anything else
|
||||
// Green Rectangles represent a MoneyPile
|
||||
Color color = Color.green;
|
||||
g2d.setColor(color);
|
||||
g2d.fillRect(j * 10, i * 10, 10, 10);
|
||||
} else if (objectHere instanceof Objective) {
|
||||
// TODO - Implement mapping of Objective
|
||||
// Should be black since they are world owned but a
|
||||
// different shape than anything else
|
||||
// Black Oval represents an Objective
|
||||
Color color = Color.black;
|
||||
g2d.setColor(color);
|
||||
g2d.fillRect(j * 10, i * 10, 10, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user