diff --git a/src/services/player/TerrainZoneInsertion.java b/src/services/player/TerrainZoneInsertion.java new file mode 100644 index 000000000..e1c7d6845 --- /dev/null +++ b/src/services/player/TerrainZoneInsertion.java @@ -0,0 +1,46 @@ +package services.player; + +import resources.Location; +import resources.Terrain; + +public class TerrainZoneInsertion { + + public static final Location getInsertionForTerrain(Terrain terrain) { + switch (terrain) { + case TATOOINE: + return generateRandomLocation(terrain, 3525, 4, -4807, 5); + case NABOO: + return generateRandomLocation(terrain, -5496, 6, 4369, 5); + case CORELLIA: + return generateRandomLocation(terrain, -145, 28, -4720, 5); + case LOK: + return generateRandomLocation(terrain, 420, 7, 5267, 5); + case DATHOMIR: + return generateRandomLocation(terrain, 5304, 78, -4135, 5); + case TALUS: + return generateRandomLocation(terrain, 336, 6, -2930, 5); + case RORI: + return generateRandomLocation(terrain, 5289, 80, 6131, 5); + case DANTOOINE: + return generateRandomLocation(terrain, -614, 3, 2527, 5); + case KASHYYYK_HUNTING: + return generateRandomLocation(terrain, 244, 41, 466, 5); + default: + return null; + } + } + + private static final Location generateRandomLocation(Terrain terrain, double x, double y, double z, double delta) { + Location location = new Location(); + location.setTerrain(terrain); + location.setX(x + (Math.random()-.5) * delta); + location.setY(y); + location.setZ(z + (Math.random()-.5) * delta); + location.setOrientationX(0); + location.setOrientationY(0); + location.setOrientationZ(0); + location.setOrientationW(1); + return location; + } + +} diff --git a/src/services/player/ZoneService.java b/src/services/player/ZoneService.java index 84948e544..43f491526 100644 --- a/src/services/player/ZoneService.java +++ b/src/services/player/ZoneService.java @@ -109,13 +109,13 @@ public class ZoneService extends Service { return; switch(p.getColor()) { - case "blue": waypoint.setColor(WaypointColor.BLUE); break; - case "green": waypoint.setColor(WaypointColor.GREEN); break; - case "orange": waypoint.setColor(WaypointColor.ORANGE); break; - case "yellow": waypoint.setColor(WaypointColor.YELLOW); break; - case "purple": waypoint.setColor(WaypointColor.PURPLE); break; - case "white": waypoint.setColor(WaypointColor.WHITE); break; - default: System.err.println("Don't know color " + p.getColor()); + case "blue": waypoint.setColor(WaypointColor.BLUE); break; + case "green": waypoint.setColor(WaypointColor.GREEN); break; + case "orange": waypoint.setColor(WaypointColor.ORANGE); break; + case "yellow": waypoint.setColor(WaypointColor.YELLOW); break; + case "purple": waypoint.setColor(WaypointColor.PURPLE); break; + case "white": waypoint.setColor(WaypointColor.WHITE); break; + default: System.err.println("Don't know color " + p.getColor()); } ghost.updateWaypoint(waypoint); @@ -307,15 +307,6 @@ public class ZoneService extends Service { } private Location getStartLocation(String start) { - Location location = new Location(); - location.setTerrain(Terrain.TATOOINE); - location.setX(3525 + (Math.random()-.5) * 5); - location.setY(4); - location.setZ(-4807 + (Math.random()-.5) * 5); - location.setOrientationX(0); - location.setOrientationY(0); - location.setOrientationZ(0); - location.setOrientationW(1); - return location; + return TerrainZoneInsertion.getInsertionForTerrain(Terrain.CORELLIA); } }