Processing unfolding maps for each marker - java

I want to add an image for each marker i have on unfolding maps
Already tried to use Buffer but im not sure what i should do now.
My main class
import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.unfolding.marker.*;
UnfoldingMap map;
import java.util.Map; // import java hashmaps
// declare country hashmaps
// key // value
HashMap<String, Country> countries = new HashMap<String, Country>();
//PGraphics buffer;
int countryNumber;
Button country;
public void setup() {
size(800, 600, P2D);
smooth();
//buffer = createGraphics(800, 600);
map = new UnfoldingMap(this);
map.setTweening(true);
map.zoomToLevel(3);
MapUtils.createDefaultEventDispatcher(this, map);
String[] lines = loadStrings("test.csv"); //read file and save lines in a string array
countryNumber = lines.length; // how many lines
println(countryNumber);
for (int i=0; i<countryNumber; i++) { //all csv lines
String line = lines[i]; /// get data from line. Ex: "Portugal,10,91"
String[] elements = split(line, ","); //separate line by ','
String name = elements[0]; // get country name
float lat = parseInt(elements[20]); // lat
float lon = parseInt(elements[21]); // lon
PImage flagIcon;
flagIcon = loadImage(elements[22]); //get image flag name
Country P = new Country(name, lat, lon, flagIcon);
Location mapMarker = new Location(lat,lon);
// Create point markers for locations
SimplePointMarker eachMapMarker = new
SimplePointMarker(mapMarker);
// Add markers to the map
map.addMarkers(eachMapMarker);
paises.put(nome, P );
}
}
public void draw() {
background(255);
map.draw(); // draw map
//image(buffer, 200, 50);
for (Map.Entry p : Countries.entrySet() ) { // get countries hashmap
Country country = (Country) p.getValue();
country.drawInfo();
country.drawCoor();
country.drawIcon();
}
}
My Country class
//my country class
class Country {
String name;
float lat;
float lon;
int posX, posY;
PImage flagIcon;
Pais (String n, float la, float lo, PImage ic) {
name = n;
lat = la;
lon = lo;
flagIcon = ic;
}
void drawIcon() {
image(flagIcon,lat,lon,16,16);
}
void drawInfo() {
Location mapLocal = new Location(lat, lon);
ScreenPosition mapPos = map.getScreenPosition(mapLocal);
float scale = map.getZoom();
// if pointer is near a country
boolean onOver = false;
if (dist(mouseX, mouseY, mapPos.x, mapPos.y)<2*scale) {
onOver = true;
}
if (onOver) {
noStroke();
//fill(255,255,255,255);
//rect(mouseX+18, mouseY-20, 120, 50);
fill(0);
text(name + "\nLat: " + lat + "\nLon: " + lon , mouseX+25, mouseY-5);
}
}
void drawCoor() {
//println(coordinates);
fill(0);
text("coordinates: " + mouseX + " " + mouseY, 650,10);
}
}
Image links are stored on my CSV
This is what im getting and as i can see my images arent synced with my lat and lon. Can anyone give me an hand ?

When you draw the country icon on the map, for the input of x and y in the image(PImage image, float x, float y) function inside drawIcon() method, you are supposed to use the marker's position on the map instead of the latitude and longitude properties.
The specific method is called getScreenPosition(UnfoldingMap map) of AbstractMarker. Please refer to the javadoc for the details. http://unfoldingmaps.org/javadoc/de/fhpotsdam/unfolding/marker/AbstractMarker.html#getScreenPosition(de.fhpotsdam.unfolding.UnfoldingMap)
The reason behind it is that (I think) the markers are added to the map with the map.addMarker method, then rendered together with the map.draw() method, where the latitude and longitude are transferred to their screen positions at the backstage.
Because you are trying to add the country icons on top of the country markers after the map.draw() method, you should try to associate the icon's position to the marker's screen position.
public void draw() {
background(200);
map.draw();
for (Marker m: countryMarkers) {
image(countryIcon, (((AbstractMarker) m).getScreenPosition(map).x,
((AbstractMarker) m).getScreenPosition(map).y);
}
}
It would also help the code look more organized and clean if you make a CountryMarker class extends SimplePointMarker class, which is available in the unfolding maps library.

Related

Java android google maps change color polyline where I was

This is how I draw a polyline :
List<LatLng> latLngsList = new ArrayList<>();
for (LegsItem leg : response.body().getRoutes().get(0).getLegs()) {
for (StepsItem step : leg.getSteps()) {
List<LatLng> latLngs = PolyUtil.decode(step.getGeometry());
step.setLatLngs(latLngs);
latLngsList.addAll(latLngs);
}
}
Polyline polyline1 = googleMap.addPolyline(new PolylineOptions()
.addAll(latLngsList));
I draw this on color black but when I am on the polyline(In LatLtg), I want to change the color to blue. To detect if I am on the point, I use the below:
mMap.setOnMyLocationChangeListener
and check if the first not done point is near than 2 m :
double dis = currentLocation.distanceTo(location);
But it does not work correctly
You can use the function distanceBetween which Computes the approximate distance in meters between two locations, and optionally the initial and final bearings of the shortest path between them.
public static boolean checkDistance(LatLng oldPosition, LatLng newPosition) {
float[] results = new float[1];
Location.distanceBetween(oldPosition.latitude, oldPosition.longitude,
newPosition.latitude, newPosition.longitude, results);
return results[0] <= 50.0;
}
Here i set minimum distance 50 meter. these will return true if your current location(latlon) is within 50 miters from your polyline latlon.
Define color value in colors.xml
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="blue">#0000EE</color>
</resources>
and set color like this :-
Polyline line = mMap.addPolyline(new PolylineOptions()
.addAll(list)
.color(R.color.blue));
EDIT
mMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
#Override
public void onMyLocationChange(Location location) {
for (LatLng nLatLng : latLngsList) {
double latitude = nLatLng.latitude;
double longitude = nLatLng.longitude;
double myLat = location.getLatitude();
double myLong = location.getLongitude();
if (latitude == myLat && longitude == myLong) {
Polyline polyline1 = googleMap.addPolyline(new PolylineOptions()
.add(nLatLng)
.color(R.color.blue));
} /*else {
Polyline polyline1 = googleMap.addPolyline(new PolylineOptions()
.add(nLatLng)
.color(R.color.black));
}*/
}
}
});
See also: update-polyline-according-to-the-user-moving-android-googlemaps

How can i properly bind the rotation property with two other properties?

I would like to draw an arrow in a JavaFX application, that rotates around an object that is bound to it (2 group objects that are connected with an arrow). To compute the correct angle I tried to compute it by substracting the two coordinates (end and start xy coordinates from the groups). But my arrow head will not move. Any ideas what I am doing wrong?
// controller code:
PlaceIcon startIconGroup = new PlaceIcon();
startIconGroup.setLayoutX(100);
startIconGroup.setLayoutY(120);
startIconGroup.addEventHandler(MouseEvent.MOUSE_CLICKED, onClickEventHandler); // for dragging
startIconGroup.addEventHandler(MouseEvent.MOUSE_DRAGGED, onDragEventHandler);
startIconGroup.addEventHandler(MouseEvent.MOUSE_PRESSED, onPressEventHandler);
workplace.getChildren().add(startIconGroup); // workplace is the pane were the nodes are shown
PlaceIcon endIconGroup = new PlaceIcon();
endIconGroup.setLayoutX(100);
endIconGroup.setLayoutY(120);
endIconGroup.addEventHandler(MouseEvent.MOUSE_CLICKED, onClickEventHandler);
endIconGroup.addEventHandler(MouseEvent.MOUSE_DRAGGED, onDragEventHandler);
endIconGroup.addEventHandler(MouseEvent.MOUSE_PRESSED, onPressEventHandler);
endIconGroup.getChildren().add(startIconGroup);
RelationIcon relationIcon = new RelationIcon();
relationIcon.setStartNode(startNode);
relationIcon.setEndNode(endNode);
...
EventHandler<MouseEvent> onDragEventHandler = new EventHandler<MouseEvent>() {
/**
* This method is used to compute the new position of an node. Therefore, the
* position in pixels (x/yLayout) is incremented by coordinate change of mouse
* movement.
*/
#Override
public void handle(MouseEvent event) {
Group clickedElement = (Group) event.getSource();
// Node node = clickedElement.getChildren().get(0);
double offsetX = event.getSceneX() - mousePosition.get().getX();
double offsetY = event.getSceneY() - mousePosition.get().getY();
clickedElement.setLayoutX(clickedElement.getLayoutX() + offsetX);
clickedElement.setLayoutY(clickedElement.getLayoutY() + offsetY);
mousePosition.set(new Point2D(event.getSceneX(), event.getSceneY()));
eventlog.setText("Move "+ clickedElement + " to x=" + clickedElement.getLayoutX() + " y="
+ clickedElement.getLayoutY());
}
};
And here is the PlaceIconClass
public class RelationIcon extends Group {
Line line;
Polygon arrowHead;
Group startNode;
Group endNode;
public RelationIcon() {
//draw arrow line
line = new Line();
// draw arrow head
arrowHead = new Polygon();
arrowHead.getPoints().addAll(new Double[]{
-10.0, -20.0,
10.0, -20.0,
0.0, 0.0});
// merge into a group
this.getChildren().addAll(line, arrowHead);
}
public Group getStartNode() {
return startNode;
}
public void setStartNode(Group startNode) {
this.startNode = startNode;
line.startXProperty().bind(this.startNode.layoutXProperty());
line.startYProperty().bind(this.startNode.layoutYProperty());
}
public Group getEndNode() {
return endNode;
}
public void setEndNode(Group endNode) {
this.endNode = endNode;
line.endXProperty().bind(this.endNode.layoutXProperty());
line.endYProperty().bind(this.endNode.layoutYProperty());
arrowHead.layoutXProperty().bind(this.endNode.layoutXProperty());
arrowHead.layoutYProperty().bind(this.endNode.layoutYProperty());
arrowHead.rotateProperty().bind(this.endNode.layoutXProperty()); // THIS WORKS
arrowHead.rotateProperty().bind(Bindings.createDoubleBinding(() -> {
double x = line.endXProperty().getValue() - line.startXProperty().getValue();
double y = line.endYProperty().getValue() - line.startYProperty().getValue();
System.out.println(x+" "+y);
double a = Math.atan2(x, y);
return Math.toDegrees(a);
})); // THIS WORKS NOT
}
Thank you for your help!

Android Google Map change polyline colors

I am drawing polylines on my Google Map. I'm doing it using:
private Map<UUID, PolylineOptions> data;
private void drawFeatures() {
for (Feature feature : features) {
feature.setUuid(UUID.fromString((String) feature.getProperties().get("id")));
PolylineOptions options = new PolylineOptions();
List<Coordinates> coordinates = ((LineString) feature.getGeometry()).getCoordinates();
for (Coordinates coordinate : coordinates) {
// can't use "addAll(...) since 'coordinates' are not instance of 'LatLng'
options.add(new LatLng(coordinate.getLatitude(), coordinate.getLongitude()));
options.color(Color.RED);
}
mMap.addPolyline(options);
data.put(feature.getUuid(), options);
}
}
And then everything is OK. All my polylines are correctly drawed using the good width and color.
However, after that, I'm trying to update the width and the color (without removing and redrawing all the polylines).
I'm trying to do it with:
private void changeColor() {
for (Map.Entry<UUID, PolylineOptions> entry : data.entrySet()) {
entry.getValue().color(Color.CYAN);
}
}
But there is no changes on my map :/ I've read the Google Developers documentation and I don't find anything about that.
How can I update the color of a polyline without having to remove and re-add it ?
PolylineOptions is just a builder for Polylines which are the objects that are drawn into the map.
Thus, changing the PolylineOptions will not affect the Polylines once they are on the map.
Your private Map<UUID, PolylineOptions> data; should be private Map<UUID, Polyline> data; and you need to add elements to the Map like this:
data.put(feature.getUuid(), mMap.addPolyline(options));
may this help you
MarkerOptions markerOptions = new MarkerOptions();
if (!status.equals("ZERO_RESULTS")) {
for (int i = 0; i < result.size(); i++) {
points = new ArrayList<LatLng>();
points.add(driverLatLng);
lineOptions = new PolylineOptions();
List<HashMap<String, String>> path = result.get(i);
for (int j = 0; j < path.size(); j++) {
HashMap<String, String> point = path.get(j);
double lat = Double.parseDouble(point.get("lat"));
double lng = Double.parseDouble(point.get("lng"));
LatLng position = new LatLng(lat, lng);
points.add(position);
}
points.add(storeLatLng);
if (points.contains(storeLongitude)) {
int index = points.indexOf(storeLongitude);
AppLog.Log(TAG, "Index Value in " + index);
int length = points.size();
points.subList(index, length - 1);
AppLog.Log(TAG, "Arraylist Size after SubList Array" + points.size());
}
lineOptions.addAll(points);
lineOptions.width(13);
lineOptions.color(getResources().getColor(R.color.title_background));
lineOptions.geodesic(true);
lineOptions.zIndex(100);
AppLog.Log(TAG, "lineOptions is" + lineOptions.getPoints());
}
mMap.addPolyline(lineOptions);
//DrawArrowHead(mMap, driverLatLng, storeLatLng);
} else {
GlobalMethod.snackBar(true,activity_driver,appContext,"no root found.");
}

Collision detection in andengine gles2

I'm trying to set up Collision detection on the cactus-property items on all cactuses in the TMXmap example from andengine Gles2. I have tried various methods - can anyone give me one that works?
Original Code
Tmxmaps andengine
One suggested solution:
collision detection
Another suggested solution:
from andengine.org
I've tried:
if(pTMXTileProperties.containsTMXProperty("cactus", "true")) {
final Rectangle rect = new Rectangle(pTMXTile.getTileX()+10, pTMXTile.getTileY(),14, 14);
final FixtureDef boxFixtureDef = PhysicsFactory.createFixtureDef(0, 0, 1f);
PhysicsFactory.createBoxBody(mPhysicsWorld, rect, BodyType.StaticBody, boxFixtureDef);
rect.setVisible(false);
mScene.attachChild(rect);
}
This is from AndEngine: Handling collisions with TMX Objects
But I get this error:
Physicsfactory not found
I'm using the TMX example you have there as a basis for my game.
This is the main block of code for collisions:
// Define the block behavior
mPathFinderMap = new IPathFinderMap<TMXLayer>(){
private boolean mCollide;
#Override
public boolean isBlocked(final int pX, final int pY, final TMXLayer pTMXLayer) {
/*
* This is where collisions happen and are detected
*/
mCollide = false;
//Null check. Used since not all tiles have properties
if(pTMXLayer.getTMXTile(pX, pY).getTMXTileProperties(mTiledMap) != null){
//Get tiles with collision property
if(pTMXLayer.getTMXTile(pX, pY).getTMXTileProperties(mTiledMap).containsTMXProperty("COLLISION", "true"))
mCollide = true;
}
if(mTMXmapLoader.getCollideTiles().contains(pTMXLayer.getTMXTile(pX, pY)))
mCollide = true;
return mCollide;
}
};
/*
* This method moves the sprite to the designated location
*/
public void walkTo(TMXTile pFinalPosition) {
if(mHasFinishedPath){
mHasFinishedPath = false;//This prevents overlapping paths when the user double clicks. Used to prevent stutter
//Player coordinates
final float[] lPlayerCordinates = mPlayerSprite.convertLocalToSceneCoordinates(mPlayerSprite.getWidth()/2, mPlayerSprite.getHeight()/2);
// Get the tile the center of the player are currently waking on.
TMXTile lPlayerPosition = SceneManager.mWorldScene.getTouchLayer().getTMXTileAt(lPlayerCordinates[Constants.VERTEX_INDEX_X], lPlayerCordinates[Constants.VERTEX_INDEX_Y]);
mFinalPosition = pFinalPosition;
// Sets the A* path from the player location to the touched location.
if(mPathFinderMap.isBlocked(pFinalPosition.getTileColumn(), pFinalPosition.getTileRow(), SceneManager.mWorldScene.getTouchLayer())){
pFinalPosition = getNextTile(lPlayerPosition, pFinalPosition);
}
// These are the parameters used to determine the
int lFromCol = lPlayerPosition.getTileColumn(); int lFromRow = lPlayerPosition.getTileRow();
int lToCol = pFinalPosition.getTileColumn(); int lToRow = pFinalPosition.getTileRow();
boolean lAllowDiagonal = false;
// Find the path. This needs to be refreshed
AStarPath = mAStarPathFinder.findPath(MAX_SEARCH_DEPTH, mPathFinderMap, 0, 0, mTiledMap.getTileColumns() - 1, mTiledMap.getTileRows() - 1, SceneManager.mWorldScene.getTouchLayer(),
lFromCol, lFromRow, lToCol, lToRow, lAllowDiagonal, mHeuristic, mCostCallback);
//Log.i("AstarPath", "AStarPath " + AStarPath);
//Only loads the path if the AStarPath is not null
Path lPlayerPath = loadPathFound();
//Log.i("AstarPath", "lPlayerPath " + lPlayerPath);
if(lPlayerPath != null)
moveSprite(lPlayerPath);//Moves the sprite along the path
else
mHasFinishedPath = true;//If the path is null the player has not moved. Set the flag to true allows input to effect the sprite
}else{
//Update parameters
mFinalPosition = pFinalPosition;
mWaypointIndex = 0;
}
}
/*
* Updates the path
*/
public void updatePath(TMXTile pFinalPosition) {
//Player coordinates
final float[] lPlayerCordinates = mPlayerSprite.convertLocalToSceneCoordinates(mPlayerSprite.getWidth()/2, mPlayerSprite.getHeight()/2);
// Get the tile the feet of the player are currently waking on.
TMXTile lPlayerPosition = SceneManager.mWorldScene.getTouchLayer().getTMXTileAt(lPlayerCordinates[Constants.VERTEX_INDEX_X], lPlayerCordinates[Constants.VERTEX_INDEX_Y]);
// Sets the A* path from the player location to the touched location.
if(mPathFinderMap.isBlocked(pFinalPosition.getTileColumn(), pFinalPosition.getTileRow(), SceneManager.mWorldScene.getTouchLayer())){
pFinalPosition = getNextTile(lPlayerPosition, pFinalPosition);
}
// Determine the tile locations
int FromCol = lPlayerPosition.getTileColumn();
int FromRow = lPlayerPosition.getTileRow();
int ToCol = pFinalPosition.getTileColumn();
int ToRow = pFinalPosition.getTileRow();
// Find the path. This needs to be refreshed
AStarPath = mAStarPathFinder.findPath(MAX_SEARCH_DEPTH, mPathFinderMap, 0, 0, mTiledMap.getTileColumns()-1, mTiledMap.getTileRows()-1, SceneManager.mWorldScene.getTouchLayer(),
FromCol, FromRow, ToCol, ToRow, false, mHeuristic, mCostCallback);
//Loads the path with the astar specifications
Path lPlayerPath = loadPathFound();
//Moves the sprite along the path
if(lPlayerPath != null){
moveSprite(lPlayerPath);
}else{
//If the path is still null after the path manipulation then the path is finished
mHasFinishedPath = true;
mWaypointIndex = 0;
//mPlayerSprite.stopAnimation();
//AStarPath = null;
}
}
The TMXmapLoader does the rest:
//Get the collision, ext, and changing tiles from the object sets on the map
mCollideTiles = this.getObjectGroupPropertyTiles("COLLIDE", TMXGroupObjects);
mExitTiles = this.getObjectPropertyTiles("EXIT", mTMXObjects);
mChangingTiles = this.getObjectGroupPropertyTiles("CHANGE", TMXGroupObjects);
...
public ArrayList<TMXTile> getCollideTiles(){
return mCollideTiles;
}
...
public ArrayList<TMXTile> getObjectGroupPropertyTiles(String pName, final int pLayer, ArrayList<TMXObjectGroup> pTMXObjectGroups){
ArrayList<TMXTile> ObjectTile = new ArrayList<TMXTile>();
for (final TMXObjectGroup pObjectGroups : pTMXObjectGroups) {
// Iterates through the properties and assigns them to the new variable
for (final TMXObjectGroupProperty pGroupProperties : pObjectGroups.getTMXObjectGroupProperties()) {
//Sees if any of the elements have this condition
if (pGroupProperties.getName().contains(pName)) {
for (final TMXObject pObjectTiles : pObjectGroups.getTMXObjects()) {
int ObjectX = pObjectTiles.getX();
int ObjectY = pObjectTiles.getY();
// Gets the number of rows and columns in the object
int ObjectRows = pObjectTiles.getHeight() / WorldActivity.TILE_HEIGHT;
int ObjectColumns = pObjectTiles.getWidth() / WorldActivity.TILE_WIDTH;
for (int TileRow = 0; TileRow < ObjectRows; TileRow++) {
for (int TileColumn = 0; TileColumn < ObjectColumns; TileColumn++) {
float lObjectTileX = ObjectX + TileColumn * WorldActivity.TILE_WIDTH;
float lObjectTileY = ObjectY + TileRow * WorldActivity.TILE_HEIGHT;
ObjectTile.add(mTMXTiledMap.getTMXLayers().get(pLayer).getTMXTileAt(lObjectTileX, lObjectTileY));
}
}
}
}
}
}
return ObjectTile;
}
I'm not familiar with android development, but the error seems to indicate that PhysicsFactory hasn't been imported. Maybe try adding an import statement like this to the top of your file?
import org.anddev.andengine.extension.physics.box2d.PhysicsFactory;

Java arraylist - Check if the two items in arraylist index are set while generating random ints from list?

My coordinates list:
int[][] coords = {
{3093, 3630 }, {3095, 3632}, {3098, 3633},
{3101, 3633 }, {3104, 3631}, {3106, 3629},
{3107, 3627}, {3108, 3624}, {3109, 3620},
{3108, 3617}, {3106, 3614}, {3102, 3613},
{3099, 3613}, {3097, 3613}, {3093, 3614},
{3090, 3617}, {3087, 3619}
};
Generation part:
int random = Misc.random(coords.length - 1);
handler.move(coords[random][0], coords[random][1], 0);
Basically what I am trying to do, if these coordinates are already taken, then re-generate the coords.
I can't really store these coords into a big arraylist, because I don't always want this feature to function, for example if I have more players than the items in the coords[] array, then this won't be activated.
Therefore I created a arraylist of used coords, and this is my logic on how to do this:
int[][] coords = {
{3093, 3630 }, {3095, 3632}, {3098, 3633},
{3101, 3633 }, {3104, 3631}, {3106, 3629},
{3107, 3627}, {3108, 3624}, {3109, 3620},
{3108, 3617}, {3106, 3614}, {3102, 3613},
{3099, 3613}, {3097, 3613}, {3093, 3614},
{3090, 3617}, {3087, 3619}
};
ArrayList<Integer> coordinates = new ArrayList<Integer>();
int random = Misc.random(coords.length - 1);
if (getPlayersCount() < coords.length) {
if (coordinates.contains(coords[random][0], coords[random][1])) {
random = Misc.random(coords.length - 1);
}
else {
handler.move(coords[random][0], coords[random][1], 0);
coords.add(coords[random][0], coords[random][1]);
}
}
else {
random = Misc.random(coords.length - 1);
handler.move(coords[random][0], coords[random][1], 0);
}
Basically, if there are less players than the array length, process.
If coordinates arraylist contains generated X, Y, regenerate it, else move player and add the coords to the list.
But it seems like I did something wrong, as I get this error: error: no suitable method found for contains(int,int)
How can I do this?
ArrayList#contains compares a Object with those objects contained within the list...
Returns true if this list contains the specified element. More
formally, returns true if and only if this list contains at least one
element e such that (o==null ? e==null : o.equals(e)).
Your list contains arrays of int, which aren't easily comparable.
It would be much easier if you used a Object whose equals method was capable of comparing the coordinates of other similar objects. Something like...
public class Coordinate {
private int latitude;
private int longitude;
public Coordinate(int latitude, int longitude) {
this.latitude = latitude;
this.longitude = longitude;
}
public int getLatitude() {
return latitude;
}
public int getLongitude() {
return longitude;
}
public boolean equals(Object value) {
boolean equals = false;
if (value instanceof Coordinate) {
Coordinate coord = (Coordinate) value;
equals = getLatitude() == coord.getLatitude() && getLongitude() == coord.getLongitude();
}
return equals;
}
//good practice to override hashcode when you override equals
public int hashcode() {
int hash = 7;
hash = 89 * hash + this.latitude;
hash = 89 * hash + this.longitude;
return hash;
}
}
Then you could use something more like...
Coordinate[] coords = {
new Coordinate(3093, 3630 ), new Coordinate(3095, 3632), new Coordinate(3098, 3633),
new Coordinate(3101, 3633 ), new Coordinate(3104, 3631), new Coordinate(3106, 3629),
new Coordinate(3107, 3627), new Coordinate(3108, 3624), new Coordinate(3109, 3620),
new Coordinate(3108, 3617), new Coordinate(3106, 3614), new Coordinate(3102, 3613),
new Coordinate(3099, 3613), new Coordinate(3097, 3613), new Coordinate(3093, 3614),
new Coordinate(3090, 3617), new Coordinate(3087, 3619)
};
ArrayList<Coordinate> coordinates = new ArrayList<Coordinate>();
int random = Misc.random(coords.length - 1);
if (getPlayersCount() < coords.length) {
Coordinate coord = new Coordinate(coords[random].getLatitude(), coords[random].getLongitude());
if (coordinates.contains(coord)) {
random = Misc.random(coords.length - 1);
}
else {
handler.move(coords[random].getLatitude(), coords[random].getLongitude(), 0);
coordinates.add(coords[random]);
}
}
else {
random = Misc.random(coords.length - 1);
handler.move(coords[random].getLatitude(), coords[random].getLongitude(), 0);
}

Categories

Resources