Merged current master in. Made changes to classes so tutorial again due to merge. #story[1189]
This commit is contained in:
@@ -71,6 +71,8 @@ public class Event {
|
|||||||
|
|
||||||
private Thread connectionThread;
|
private Thread connectionThread;
|
||||||
|
|
||||||
|
private int mapIndex;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -84,8 +86,10 @@ public class Event {
|
|||||||
|
|
||||||
// System.out.println(XMLUtilities.validateXML(this.getClass().getClassLoader().getResource("mock/mockXML/iMapLayout.xml").toString()
|
// System.out.println(XMLUtilities.validateXML(this.getClass().getClassLoader().getResource("mock/mockXML/iMapLayout.xml").toString()
|
||||||
// , this.getClass().getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd")));
|
// , this.getClass().getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd")));
|
||||||
|
this.mapIndex = mapIndex;
|
||||||
String raceXMLFile;
|
String raceXMLFile;
|
||||||
|
String boatsXMLFile = "mock/mockXML/boatTest.xml";
|
||||||
|
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
|
||||||
switch (mapIndex){
|
switch (mapIndex){
|
||||||
case 0:raceXMLFile = "mock/mockXML/raceSixPlayers.xml";
|
case 0:raceXMLFile = "mock/mockXML/raceSixPlayers.xml";
|
||||||
break;
|
break;
|
||||||
@@ -95,11 +99,15 @@ public class Event {
|
|||||||
break;
|
break;
|
||||||
case 3: raceXMLFile = "mock/mockXML/mMapLayout.xml";
|
case 3: raceXMLFile = "mock/mockXML/mMapLayout.xml";
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
raceXMLFile = "mock/mockXML/raceTutorial.xml";
|
||||||
|
boatsXMLFile = "mock/mockXML/boatTutorial.xml";
|
||||||
|
regattaXMLFile = "mock/mockXML/regattaTutorial.xml";
|
||||||
|
break;
|
||||||
default: raceXMLFile = "mock/mockXML/raceSixPlayers.xml";
|
default: raceXMLFile = "mock/mockXML/raceSixPlayers.xml";
|
||||||
|
|
||||||
}
|
}
|
||||||
String boatsXMLFile = "mock/mockXML/boatTest.xml";
|
|
||||||
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
|
|
||||||
|
|
||||||
if (singlePlayer) {
|
if (singlePlayer) {
|
||||||
raceXMLFile = "mock/mockXML/raceSinglePlayer.xml";
|
raceXMLFile = "mock/mockXML/raceSinglePlayer.xml";
|
||||||
@@ -111,7 +119,9 @@ public class Event {
|
|||||||
//this.raceXML = RaceXMLCreator.alterRaceToWind(raceXMLFile, 90);
|
//this.raceXML = RaceXMLCreator.alterRaceToWind(raceXMLFile, 90);
|
||||||
this.raceXML = XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8);
|
this.raceXML = XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8);
|
||||||
this.raceXML = Event.setRaceXMLAtCurrentTimeToNow(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8));
|
this.raceXML = Event.setRaceXMLAtCurrentTimeToNow(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8));
|
||||||
|
if(mapIndex==4){
|
||||||
|
this.raceXML = Event.setRaceXMLAtCurrentTimeToNow(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8), 1000, 5000);
|
||||||
|
}
|
||||||
this.boatXML = XMLReader.readXMLFileToString(boatsXMLFile, StandardCharsets.UTF_8);
|
this.boatXML = XMLReader.readXMLFileToString(boatsXMLFile, StandardCharsets.UTF_8);
|
||||||
this.regattaXML = XMLReader.readXMLFileToString(regattaXMLFile, StandardCharsets.UTF_8);
|
this.regattaXML = XMLReader.readXMLFileToString(regattaXMLFile, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
@@ -194,9 +204,15 @@ public class Event {
|
|||||||
* @return String containing edited xml
|
* @return String containing edited xml
|
||||||
*/
|
*/
|
||||||
public static String setRaceXMLAtCurrentTimeToNow(String raceXML) {
|
public static String setRaceXMLAtCurrentTimeToNow(String raceXML) {
|
||||||
|
return setRaceXMLAtCurrentTimeToNow(raceXML, Constants.RacePreStartTime, Constants.RacePreparatoryTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String setRaceXMLAtCurrentTimeToNow(String raceXML, long racePreStartTime, long racePreparatoryTime){
|
||||||
//The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute.
|
//The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute.
|
||||||
long millisecondsToAdd = Constants.RacePreStartTime + Constants.RacePreparatoryTime;
|
|
||||||
|
long millisecondsToAdd = racePreStartTime + racePreparatoryTime;
|
||||||
|
|
||||||
|
|
||||||
long secondsToAdd = millisecondsToAdd / 1000;
|
long secondsToAdd = millisecondsToAdd / 1000;
|
||||||
//Scale the time using our time scalar.
|
//Scale the time using our time scalar.
|
||||||
secondsToAdd = secondsToAdd / Constants.RaceTimeScale;
|
secondsToAdd = secondsToAdd / Constants.RaceTimeScale;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class RaceXMLCreator {
|
|||||||
* @throws SAXException error in schema file
|
* @throws SAXException error in schema file
|
||||||
* @throws ParserConfigurationException error in parsing the schema file
|
* @throws ParserConfigurationException error in parsing the schema file
|
||||||
*/
|
*/
|
||||||
public static String alterRaceToWind(String s, double degrees) throws XMLReaderException, InvalidRaceDataException, JAXBException, IOException, SAXException, ParserConfigurationException {
|
public static String alterRaceToWind(String s, double degrees, boolean tutorial) throws XMLReaderException, InvalidRaceDataException, JAXBException, IOException, SAXException, ParserConfigurationException {
|
||||||
RaceXMLReader reader = new RaceXMLReader(s, XMLFileType.ResourcePath);
|
RaceXMLReader reader = new RaceXMLReader(s, XMLFileType.ResourcePath);
|
||||||
|
|
||||||
XMLRace race = XMLUtilities.xmlToClass(
|
XMLRace race = XMLUtilities.xmlToClass(
|
||||||
@@ -82,7 +82,11 @@ public class RaceXMLCreator {
|
|||||||
RaceXMLCreator.class.getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd"),
|
RaceXMLCreator.class.getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd"),
|
||||||
XMLRace.class);
|
XMLRace.class);
|
||||||
|
|
||||||
|
if(tutorial){
|
||||||
|
setRaceXMLAtCurrentTimeToNow(race, 1000l, 5000l);
|
||||||
|
} else {
|
||||||
setRaceXMLAtCurrentTimeToNow(race);
|
setRaceXMLAtCurrentTimeToNow(race);
|
||||||
|
}
|
||||||
|
|
||||||
double raceOriginalBearing = getLineAngle(getLeewardGate(reader).getMark1Position(), getWindwardGate(reader).getMark1Position());
|
double raceOriginalBearing = getLineAngle(getLeewardGate(reader).getMark1Position(), getWindwardGate(reader).getMark1Position());
|
||||||
|
|
||||||
@@ -93,6 +97,7 @@ public class RaceXMLCreator {
|
|||||||
return XMLUtilities.classToXML(race);
|
return XMLUtilities.classToXML(race);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotate the features in a race such as the boundary, and the marks.
|
* Rotate the features in a race such as the boundary, and the marks.
|
||||||
* @param race the race to alter
|
* @param race the race to alter
|
||||||
@@ -180,14 +185,11 @@ public class RaceXMLCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the xml description of the race to show the race was created now, and starts in 4 minutes
|
|
||||||
* @param raceXML The race.xml contents.
|
|
||||||
*/
|
|
||||||
public static void setRaceXMLAtCurrentTimeToNow(XMLRace raceXML) {
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void setRaceXMLAtCurrentTimeToNow(XMLRace raceXML, long racePrestartTime, long racePreparatoryTime){
|
||||||
//The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute.
|
//The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute.
|
||||||
long millisecondsToAdd = Constants.RacePreStartTime + Constants.RacePreparatoryTime;
|
long millisecondsToAdd = racePrestartTime + racePreparatoryTime;
|
||||||
long secondsToAdd = millisecondsToAdd / 1000;
|
long secondsToAdd = millisecondsToAdd / 1000;
|
||||||
//Scale the time using our time scalar.
|
//Scale the time using our time scalar.
|
||||||
secondsToAdd = secondsToAdd / Constants.RaceTimeScale;
|
secondsToAdd = secondsToAdd / Constants.RaceTimeScale;
|
||||||
@@ -198,4 +200,13 @@ public class RaceXMLCreator {
|
|||||||
raceXML.getRaceStartTime().setTime(dateFormat.format(creationTime.plusSeconds(secondsToAdd)));
|
raceXML.getRaceStartTime().setTime(dateFormat.format(creationTime.plusSeconds(secondsToAdd)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the xml description of the race to show the race was created now, and starts in 4 minutes
|
||||||
|
* @param raceXML The race.xml contents.
|
||||||
|
*/
|
||||||
|
public static void setRaceXMLAtCurrentTimeToNow(XMLRace raceXML) {
|
||||||
|
setRaceXMLAtCurrentTimeToNow(raceXML, Constants.RacePreStartTime, Constants.RacePreparatoryTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,9 +137,9 @@ public class HostController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setGameType(int gameType){
|
public void setGameType(int gameType){
|
||||||
this.gameType = gameType;
|
this.currentMapIndex = gameType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGameType(){ return this.gameType; }
|
public int getGameType(){ return this.currentMapIndex; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ public class RaceController extends Controller {
|
|||||||
|
|
||||||
|
|
||||||
//Check if the game is a tutorial
|
//Check if the game is a tutorial
|
||||||
if (parent.getGameType()==2){
|
if (parent.getGameType()==4){
|
||||||
isTutorial = true;
|
isTutorial = true;
|
||||||
tutorialText.setVisible(true);
|
tutorialText.setVisible(true);
|
||||||
tutorialStates = new ArrayList<>(Arrays.asList(TutorialState.values()));
|
tutorialStates = new ArrayList<>(Arrays.asList(TutorialState.values()));
|
||||||
|
|||||||
@@ -215,6 +215,8 @@ public class StartController extends Controller {
|
|||||||
* Countdown timer until race starts.
|
* Countdown timer until race starts.
|
||||||
*/
|
*/
|
||||||
private void countdownTimer() {
|
private void countdownTimer() {
|
||||||
|
System.out.println(parent.getGameType());
|
||||||
|
|
||||||
new AnimationTimer() {
|
new AnimationTimer() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(long arg0) {
|
public void handle(long arg0) {
|
||||||
@@ -238,6 +240,7 @@ public class StartController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public class TitleController extends Controller {
|
|||||||
public void tutorialStartPressed() throws IOException {
|
public void tutorialStartPressed() throws IOException {
|
||||||
titleWrapper.setVisible(false);
|
titleWrapper.setVisible(false);
|
||||||
System.out.println("Start the tutorial!");
|
System.out.println("Start the tutorial!");
|
||||||
parent.setGameType(2);
|
parent.setGameType(4);
|
||||||
parent.beginGame();
|
parent.beginGame();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user