-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 IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
public static void initializeDrones() throws ClassNotFoundException,
|
public static void initializeDrones() throws ClassNotFoundException, IOException {
|
||||||
IOException {
|
|
||||||
if (Nomads.DEBUGSTATUS)
|
if (Nomads.DEBUGSTATUS)
|
||||||
System.out.println("Loading the drones into world...");
|
System.out.println("Loading the drones into world...");
|
||||||
/*
|
/*
|
||||||
@ -53,11 +52,10 @@ public class InitializeGame {
|
|||||||
if (Nomads.DEBUGSTATUS)
|
if (Nomads.DEBUGSTATUS)
|
||||||
System.out.println("Loading " + filename);
|
System.out.println("Loading " + filename);
|
||||||
|
|
||||||
File file = new File(System.getProperty("user.dir") + "/drones/"
|
File file = new File(System.getProperty("user.dir") + "/drones/" + filename);
|
||||||
+ filename);
|
|
||||||
|
|
||||||
URLClassLoader clazzLoader = URLClassLoader
|
URLClassLoader clazzLoader = URLClassLoader.newInstance(new URL[] { file.toURI()
|
||||||
.newInstance(new URL[] { file.toURI().toURL() });
|
.toURL() });
|
||||||
// System.class.getClassLoader()
|
// System.class.getClassLoader()
|
||||||
|
|
||||||
JarFile jarFile = new JarFile(file);
|
JarFile jarFile = new JarFile(file);
|
||||||
@ -68,8 +66,8 @@ public class InitializeGame {
|
|||||||
if (element.getName().endsWith(className + ".class")) {
|
if (element.getName().endsWith(className + ".class")) {
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Class c = clazzLoader.loadClass(element.getName()
|
Class c = clazzLoader.loadClass(element.getName().replaceAll(".class", "")
|
||||||
.replaceAll(".class", "").replaceAll("/", "."));
|
.replaceAll("/", "."));
|
||||||
|
|
||||||
// Create new GameObject
|
// Create new GameObject
|
||||||
GameObject newGameObject = (GameObject) c.newInstance();
|
GameObject newGameObject = (GameObject) c.newInstance();
|
||||||
@ -151,8 +149,7 @@ public class InitializeGame {
|
|||||||
|
|
||||||
Building townHall = new Building(Structure.TOWNHALL, 30, 40, null);
|
Building townHall = new Building(Structure.TOWNHALL, 30, 40, null);
|
||||||
Building upgradeShop = new Building(Structure.UPGRADESHOP, 30, 60, null);
|
Building upgradeShop = new Building(Structure.UPGRADESHOP, 30, 60, null);
|
||||||
Building policeStation = new Building(Structure.POLICESTATION, 50, 40,
|
Building policeStation = new Building(Structure.POLICESTATION, 50, 40, null);
|
||||||
null);
|
|
||||||
Building RepairShop = new Building(Structure.REPAIRSHOP, 50, 60, null);
|
Building RepairShop = new Building(Structure.REPAIRSHOP, 50, 60, null);
|
||||||
|
|
||||||
if (Nomads.DEBUGSTATUS)
|
if (Nomads.DEBUGSTATUS)
|
||||||
@ -170,10 +167,10 @@ public class InitializeGame {
|
|||||||
/**
|
/**
|
||||||
* Generate the money piles and place them on the map
|
* 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++) {
|
for (int i = 0; i < Nomads.MONEYPILES; i++) {
|
||||||
MoneyPile newPile = new MoneyPile();
|
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
|
// Generate and place all required buildings into world
|
||||||
if (DEBUGSTATUS)
|
if (DEBUGSTATUS)
|
||||||
|
System.out.println("Initializing and placing buildings");
|
||||||
InitializeGame.initializeBuildngs(awesomeWorld);
|
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
|
// Check to make sure allTeams has been set up properly
|
||||||
if (allTeams == null) {
|
if (allTeams == null) {
|
||||||
// Do something awesome
|
// Do something awesome
|
||||||
|
@ -173,6 +173,7 @@ public class World {
|
|||||||
* GameObject to be placed
|
* GameObject to be placed
|
||||||
*/
|
*/
|
||||||
public void setObjectRandom(GameObject newItem) {
|
public void setObjectRandom(GameObject newItem) {
|
||||||
|
// TODO - Able to go out of bounds
|
||||||
// Min + (int)(Math.random() * ((Max - Min) + 1))
|
// Min + (int)(Math.random() * ((Max - Min) + 1))
|
||||||
int randX = 0 + (int) (Math.random() * ((getWorldSize() - 0) + 1));
|
int randX = 0 + (int) (Math.random() * ((getWorldSize() - 0) + 1));
|
||||||
int randY = 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.setColor(Color.black);
|
||||||
g2d.fillRect(j * 10, i * 10, 10, 10);
|
g2d.fillRect(j * 10, i * 10, 10, 10);
|
||||||
} else if (objectHere instanceof MoneyPile) {
|
} else if (objectHere instanceof MoneyPile) {
|
||||||
// TODO - Implement mapping of MoneyPiles
|
// Green Rectangles represent a MoneyPile
|
||||||
// Should be black since they are world owned but a
|
Color color = Color.green;
|
||||||
// different shape than anything else
|
g2d.setColor(color);
|
||||||
|
g2d.fillRect(j * 10, i * 10, 10, 10);
|
||||||
} else if (objectHere instanceof Objective) {
|
} else if (objectHere instanceof Objective) {
|
||||||
// TODO - Implement mapping of Objective
|
// Black Oval represents an Objective
|
||||||
// Should be black since they are world owned but a
|
Color color = Color.black;
|
||||||
// different shape than anything else
|
g2d.setColor(color);
|
||||||
|
g2d.fillRect(j * 10, i * 10, 10, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user