mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Added per map max player count. Handles case when map cannot fit players behind start mark. Added initial implementation for spacing out yachts.
#implement #story[1275]
This commit is contained in:
@@ -254,8 +254,8 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
serverToClientThread.addConnectionListener(this::sendSetupMessages);
|
|
||||||
MessageFactory.updateBoats(new ArrayList<>(GameState.getYachts().values()));
|
MessageFactory.updateBoats(new ArrayList<>(GameState.getYachts().values()));
|
||||||
|
serverToClientThread.addConnectionListener(this::sendSetupMessages);
|
||||||
}
|
}
|
||||||
serverToClientThreads.add(serverToClientThread);
|
serverToClientThreads.add(serverToClientThread);
|
||||||
serverToClientThread.addDisconnectListener(this::clientDisconnected);
|
serverToClientThread.addDisconnectListener(this::clientDisconnected);
|
||||||
@@ -366,13 +366,75 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
|||||||
// boatIndex++;
|
// boatIndex++;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
final double SEPARATION = 50.0; // distance apart in meters
|
// final double SEPARATION = 50.0; // distance apart in meters
|
||||||
|
//
|
||||||
|
// //Reverse of the angle from start to first mark
|
||||||
|
// double angleToFirstMark = 360 - GeoUtility.getBearing(
|
||||||
|
// GameState.getMarkOrder().getMarkOrder().get(0).getMidPoint(),
|
||||||
|
// GameState.getMarkOrder().getMarkOrder().get(1).getMidPoint()
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// //Length of start line
|
||||||
|
// double startLineLength = GeoUtility.getDistance(
|
||||||
|
// GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(1),
|
||||||
|
// GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(2)
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// //Angle of start line
|
||||||
|
// double startMarkToMarkAngle = GeoUtility.getBearing(
|
||||||
|
// GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(1),
|
||||||
|
// GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(2)
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// //How many yachts can fit along the start line
|
||||||
|
// int spacesAlongLine = (int) Math.round(startLineLength / SEPARATION);
|
||||||
|
// //The free space left by the boats.
|
||||||
|
// double buffer = (startLineLength % SEPARATION) / 2;
|
||||||
|
//
|
||||||
|
// //Randomize starting order.
|
||||||
|
// List<ServerYacht> serverYachtList = new ArrayList<>(GameState.getYachts().values());
|
||||||
|
// Collections.shuffle(serverYachtList);
|
||||||
|
//
|
||||||
|
// //set the starting point away from start line.
|
||||||
|
// GeoPoint startingPoint = GeoUtility.getGeoCoordinate(
|
||||||
|
// GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(1),
|
||||||
|
// angleToFirstMark, SEPARATION
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// //Move it along the start line
|
||||||
|
// startingPoint = GeoUtility.getGeoCoordinate(
|
||||||
|
// startingPoint, startMarkToMarkAngle, buffer
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// int yachtCount = 0;
|
||||||
|
// int repeats = 0;
|
||||||
|
//
|
||||||
|
// GeoPoint yachtLocation;
|
||||||
|
//
|
||||||
|
// for (ServerYacht serverYacht : serverYachtList) {
|
||||||
|
//
|
||||||
|
// //Move away from start line
|
||||||
|
// yachtLocation = GeoUtility.getGeoCoordinate(
|
||||||
|
// startingPoint, angleToFirstMark,repeats * SEPARATION
|
||||||
|
// );
|
||||||
|
// //Move along start line
|
||||||
|
// yachtLocation = GeoUtility.getGeoCoordinate(
|
||||||
|
// yachtLocation, startMarkToMarkAngle, yachtCount * SEPARATION
|
||||||
|
// );
|
||||||
|
// serverYacht.setLocation(yachtLocation);
|
||||||
|
// serverYacht.setHeading(GeoUtility.getBearing(
|
||||||
|
// yachtLocation, GameState.getMarkOrder().getMarkOrder().get(1).getMidPoint()
|
||||||
|
// ));
|
||||||
|
// //Set location for next yacht
|
||||||
|
// yachtCount++;
|
||||||
|
// if (yachtCount > spacesAlongLine) {
|
||||||
|
// yachtCount = 0;
|
||||||
|
// repeats++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
//Reverse of the angle from start to first mark
|
final double DISTANCE_TO_START = 75d;
|
||||||
double angleToFirstMark = 360 - GeoUtility.getBearing(
|
final double YACHT_SEPARATION = 20d;
|
||||||
GameState.getMarkOrder().getMarkOrder().get(0).getMidPoint(),
|
|
||||||
GameState.getMarkOrder().getMarkOrder().get(1).getMidPoint()
|
|
||||||
);
|
|
||||||
|
|
||||||
//Length of start line
|
//Length of start line
|
||||||
double startLineLength = GeoUtility.getDistance(
|
double startLineLength = GeoUtility.getDistance(
|
||||||
@@ -380,57 +442,54 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
|||||||
GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(2)
|
GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(2)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//How many yachts can fit along the start line
|
||||||
|
int spacesAlongLine = (int) Math.round(startLineLength / YACHT_SEPARATION);
|
||||||
|
|
||||||
//Angle of start line
|
//Angle of start line
|
||||||
double startMarkToMarkAngle = GeoUtility.getBearing(
|
double startMarkToMarkAngle = GeoUtility.getBearing(
|
||||||
GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(1),
|
GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(1),
|
||||||
GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(2)
|
GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(2)
|
||||||
);
|
);
|
||||||
|
|
||||||
//How many yachts can fit along the start line
|
//angle from first mark to the start
|
||||||
int spacesAlongLine = (int) Math.round(startLineLength / SEPARATION);
|
double angleToStart = GeoUtility.getBearing(
|
||||||
//The free space left by the boats.
|
GameState.getMarkOrder().getMarkOrder().get(1).getMidPoint(),
|
||||||
double buffer = (startLineLength % SEPARATION) / 2;
|
GameState.getMarkOrder().getMarkOrder().get(0).getMidPoint()
|
||||||
|
);
|
||||||
|
|
||||||
//Randomize starting order.
|
double angleFromStart = GeoUtility.getBearing(
|
||||||
List<ServerYacht> serverYachtList = new ArrayList<>(GameState.getYachts().values());
|
GameState.getMarkOrder().getMarkOrder().get(0).getMidPoint(),
|
||||||
Collections.shuffle(serverYachtList);
|
GameState.getMarkOrder().getMarkOrder().get(1).getMidPoint()
|
||||||
|
);
|
||||||
|
|
||||||
//set the starting point away from start line.
|
|
||||||
GeoPoint startingPoint = GeoUtility.getGeoCoordinate(
|
GeoPoint startingPoint = GeoUtility.getGeoCoordinate(
|
||||||
GameState.getMarkOrder().getMarkOrder().get(0).getSubMark(1),
|
GameState.getMarkOrder().getMarkOrder().get(0).getMidPoint(),
|
||||||
angleToFirstMark, SEPARATION
|
angleToStart, DISTANCE_TO_START
|
||||||
);
|
);
|
||||||
|
|
||||||
//Move it along the start line
|
List<ServerYacht> randomisedYachts = new ArrayList<>(GameState.getYachts().values());
|
||||||
startingPoint = GeoUtility.getGeoCoordinate(
|
Collections.shuffle(randomisedYachts);
|
||||||
startingPoint, startMarkToMarkAngle, buffer
|
while (randomisedYachts.size() > 0) {
|
||||||
);
|
|
||||||
|
|
||||||
int yachtCount = 0;
|
int numYachtsInLine = spacesAlongLine > randomisedYachts.size() ? randomisedYachts.size() : spacesAlongLine;
|
||||||
int repeats = 0;
|
double yachtSpace = numYachtsInLine * YACHT_SEPARATION / 2;
|
||||||
|
|
||||||
GeoPoint yachtLocation;
|
GeoPoint firstYachtPoint = GeoUtility.getGeoCoordinate(
|
||||||
|
startingPoint, startMarkToMarkAngle + 180, yachtSpace
|
||||||
for (ServerYacht serverYacht : serverYachtList) {
|
|
||||||
|
|
||||||
//Move away from start line
|
|
||||||
yachtLocation = GeoUtility.getGeoCoordinate(
|
|
||||||
startingPoint, angleToFirstMark,repeats * SEPARATION
|
|
||||||
);
|
);
|
||||||
//Move along start line
|
|
||||||
yachtLocation = GeoUtility.getGeoCoordinate(
|
for (int i=0; i<numYachtsInLine; i++){
|
||||||
yachtLocation, startMarkToMarkAngle, yachtCount * SEPARATION
|
randomisedYachts.get(0).setHeading(angleFromStart);
|
||||||
);
|
randomisedYachts.get(0).setLocation(firstYachtPoint);
|
||||||
serverYacht.setLocation(yachtLocation);
|
firstYachtPoint = GeoUtility.getGeoCoordinate(
|
||||||
serverYacht.setHeading(GeoUtility.getBearing(
|
firstYachtPoint, startMarkToMarkAngle, yachtSpace
|
||||||
yachtLocation, GameState.getMarkOrder().getMarkOrder().get(1).getMidPoint()
|
);
|
||||||
));
|
randomisedYachts.remove(0);
|
||||||
//Set location for next yacht
|
|
||||||
yachtCount++;
|
|
||||||
if (yachtCount > spacesAlongLine) {
|
|
||||||
yachtCount = 0;
|
|
||||||
repeats++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startingPoint = GeoUtility.getGeoCoordinate(
|
||||||
|
startingPoint, angleToStart, DISTANCE_TO_START
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ public class MessageFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updateBoats(List<ServerYacht> yachts) {
|
public static void updateBoats(List<ServerYacht> yachts) {
|
||||||
|
for (ServerYacht serverYacht : yachts) {
|
||||||
|
System.out.println(serverYacht);
|
||||||
|
}
|
||||||
xmlGenerator.getRace().setBoats(yachts);
|
xmlGenerator.getRace().setBoats(yachts);
|
||||||
String xmlStr = xmlGenerator.getBoatsAsXml();
|
String xmlStr = xmlGenerator.getBoatsAsXml();
|
||||||
MessageFactory.boats = new XMLMessage(xmlStr, XMLMessageSubType.BOAT, xmlStr.length());
|
MessageFactory.boats = new XMLMessage(xmlStr, XMLMessageSubType.BOAT, xmlStr.length());
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package seng302.visualiser;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -24,7 +23,6 @@ import javafx.scene.transform.Translate;
|
|||||||
import seng302.gameServer.messages.RoundingSide;
|
import seng302.gameServer.messages.RoundingSide;
|
||||||
import seng302.model.ClientYacht;
|
import seng302.model.ClientYacht;
|
||||||
import seng302.model.GameKeyBind;
|
import seng302.model.GameKeyBind;
|
||||||
import seng302.model.GeoPoint;
|
|
||||||
import seng302.model.KeyAction;
|
import seng302.model.KeyAction;
|
||||||
import seng302.model.Limit;
|
import seng302.model.Limit;
|
||||||
import seng302.model.ScaledPoint;
|
import seng302.model.ScaledPoint;
|
||||||
@@ -79,6 +77,8 @@ public class GameView3D extends GameView{
|
|||||||
topDownCam = new TopDownCamera();
|
topDownCam = new TopDownCamera();
|
||||||
chaseCam = new ChaseCamera();
|
chaseCam = new ChaseCamera();
|
||||||
|
|
||||||
|
canvasWidth = canvasHeight = 300;
|
||||||
|
|
||||||
for (PerspectiveCamera pc : Arrays.asList(isometricCam, topDownCam, chaseCam)) {
|
for (PerspectiveCamera pc : Arrays.asList(isometricCam, topDownCam, chaseCam)) {
|
||||||
pc.setFarClip(600);
|
pc.setFarClip(600);
|
||||||
pc.setNearClip(0.1);
|
pc.setNearClip(0.1);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<Marks>
|
<Marks>
|
||||||
<CompoundMark CompoundMarkID="1">
|
<CompoundMark CompoundMarkID="1">
|
||||||
<Mark Lat="-14.071412" Lng="47.05756"/>
|
<Mark Lat="-14.071412" Lng="47.05756"/>
|
||||||
<Mark Lat="-14.070814" Lng="47.058041"/>
|
<Mark Lat="-14.069914" Lng="47.058541"/>
|
||||||
</CompoundMark>
|
</CompoundMark>
|
||||||
<CompoundMark CompoundMarkID="2">
|
<CompoundMark CompoundMarkID="2">
|
||||||
<Mark Lat="-14.067194" Lng="47.053818" />
|
<Mark Lat="-14.067194" Lng="47.053818" />
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
<CourseLimit>
|
<CourseLimit>
|
||||||
<Limit Lat="-14.073371" Lng="47.058213" />
|
<Limit Lat="-14.073371" Lng="47.058213" />
|
||||||
<Limit Lat="-14.06653" Lng="47.051003" />
|
<Limit Lat="-14.06453" Lng="47.050003" />
|
||||||
<Limit Lat="-14.059022" Lng="47.057286" />
|
<Limit Lat="-14.059022" Lng="47.057286" />
|
||||||
<Limit Lat="-14.058723" Lng="47.064358" />
|
<Limit Lat="-14.058723" Lng="47.064358" />
|
||||||
<Limit Lat="-14.06261" Lng="47.071293" />
|
<Limit Lat="-14.06261" Lng="47.071293" />
|
||||||
|
|||||||
Reference in New Issue
Block a user