Tutorial option in title screen will now created a game with tutorial xmls. Host game will now created a game with the race xml instead of tutorial xml as well. Made changes to tutorial label in title. #story[1189]

main
David Wu 8 years ago
parent c7af4f2eb7
commit ea029baf22

@ -21,7 +21,7 @@ public class App extends Application {
public void start(Stage primaryStage) {
try {
//TODO should read a configuration file to configure server?
Event raceEvent = new Event(false);
Event raceEvent = new Event(0);
} catch (Exception e) {

@ -74,23 +74,29 @@ public class Event {
/**
* Constructs an event, using various XML files.
* @param singlePlayer Whether or not to create a single player event.
* @param gameType Type of game to create. Determines which XML files to send
* @throws EventConstructionException Thrown if we cannot create an Event for any reason.
*/
public Event(boolean singlePlayer) throws EventConstructionException {
public Event(int gameType) throws EventConstructionException {
//String raceXMLFile = "mock/mockXML/raceTest.xml";
String raceXMLFile = "mock/mockXML/raceTutorial.xml";
//String boatsXMLFile = "mock/mockXML/boatTest.xml";
String boatsXMLFile = "mock/mockXML/boatTutorial.xml";
//String regattaXMLFile = "mock/mockXML/regattaTest.xml";
String regattaXMLFile = "mock/mockXML/regattaTutorial.xml";
String raceXMLFile = "mock/mockXML/raceTest.xml";
if (singlePlayer) {
String boatsXMLFile = "mock/mockXML/boatTest.xml";
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
if (gameType == 1) {
raceXMLFile = "mock/mockXML/raceSinglePlayer.xml";
boatsXMLFile = "mock/mockXML/boatsSinglePlayer.xml";
}
if (gameType == 2){
raceXMLFile = "mock/mockXML/raceTutorial.xml";
boatsXMLFile = "mock/mockXML/boatTutorial.xml";
regattaXMLFile = "mock/mockXML/regattaTutorial.xml";
}
//Read XML files.
try {
//this.raceXML = RaceXMLCreator.alterRaceToWind(raceXMLFile, 90);

@ -37,6 +37,8 @@ public class HostController extends Controller {
private Event game;
private int gameType = 0;
@Override
public void initialize(URL location, ResourceBundle resources) {
@ -48,7 +50,7 @@ public class HostController extends Controller {
*/
public void hostGamePressed() throws IOException{
try {
this.game = new Event(false);
this.game = new Event(gameType);
connectSocket("localhost", 4942);
} catch (EventConstructionException e) {
Logger.getGlobal().log(Level.SEVERE, "Could not create Event.", e);
@ -89,4 +91,8 @@ public class HostController extends Controller {
parent.enterTitle();
}
public void setGameType(int gameType){
this.gameType = gameType;
}
}

@ -94,6 +94,10 @@ public class MainController extends Controller {
hostController.hostGamePressed();
}
public void setGameType(int gameType){
hostController.setGameType(gameType);
}
/**
* Main Controller for the applications will house the menu and the displayed pane.
*

@ -47,6 +47,7 @@ public class TitleController extends Controller {
*/
public void hostAGame() throws IOException {
titleWrapper.setVisible(false);
parent.setGameType(0);
parent.hostGame();
App.getStage().setResizable(true);
}
@ -117,6 +118,7 @@ public class TitleController extends Controller {
public void tutorialStartPressed() throws IOException {
titleWrapper.setVisible(false);
System.out.println("Start the tutorial!");
parent.setGameType(2);
parent.beginGame();
}

@ -80,11 +80,7 @@
<Font name="Comic Sans MS Bold" size="16.0" />
</font>
</Button>
<Label fx:id="tutorialLabel" layoutX="94.0" layoutY="271.0" onMouseClicked="#tutorialStartPressed" style="-fx-shape: &quot;M 45.673,0 C 67.781,0 85.703,12.475 85.703,27.862 C 85.703,43.249 67.781,55.724 45.673,55.724 C 38.742,55.724 32.224,54.497 26.539,52.34 C 15.319,56.564 0,64.542 0,64.542 C 0,64.542 9.989,58.887 14.107,52.021 C 15.159,50.266 15.775,48.426 16.128,46.659 C 9.618,41.704 5.643,35.106 5.643,27.862 C 5.643,12.475 23.565,0 45.673,0 M 45.673,2.22 C 24.824,2.22 7.862,13.723 7.862,27.863 C 7.862,34.129 11.275,40.177 17.472,44.893 L 18.576,45.734 L 18.305,47.094 C 17.86,49.324 17.088,51.366 16.011,53.163 C 15.67,53.73 15.294,54.29 14.891,54.837 C 18.516,53.191 22.312,51.561 25.757,50.264 L 26.542,49.968 L 27.327,50.266 C 32.911,52.385 39.255,53.505 45.673,53.505 C 66.522,53.505 83.484,42.002 83.484,27.862 C 83.484,13.722 66.522,2.22 45.673,2.22 L 45.673,2.22 z &quot;; -fx-background-color: black, white; -fx-background-insets: 0,1; -fx-padding: 50;" text="How do I play this game?">
<font>
<Font size="15.0" />
</font>
</Label>
<Label fx:id="tutorialLabel" layoutX="94.0" layoutY="223.0" onMouseClicked="#tutorialStartPressed" prefHeight="167.0" prefWidth="206.0" style="-fx-shape: &quot;M 45.673,0 C 67.781,0 85.703,12.475 85.703,27.862 C 85.703,43.249 67.781,55.724 45.673,55.724 C 38.742,55.724 32.224,54.497 26.539,52.34 C 15.319,56.564 0,64.542 0,64.542 C 0,64.542 9.989,58.887 14.107,52.021 C 15.159,50.266 15.775,48.426 16.128,46.659 C 9.618,41.704 5.643,35.106 5.643,27.862 C 5.643,12.475 23.565,0 45.673,0 M 45.673,2.22 C 24.824,2.22 7.862,13.723 7.862,27.863 C 7.862,34.129 11.275,40.177 17.472,44.893 L 18.576,45.734 L 18.305,47.094 C 17.86,49.324 17.088,51.366 16.011,53.163 C 15.67,53.73 15.294,54.29 14.891,54.837 C 18.516,53.191 22.312,51.561 25.757,50.264 L 26.542,49.968 L 27.327,50.266 C 32.911,52.385 39.255,53.505 45.673,53.505 C 66.522,53.505 83.484,42.002 83.484,27.862 C 83.484,13.722 66.522,2.22 45.673,2.22 L 45.673,2.22 z &quot;; -fx-background-color: black, white; -fx-background-insets: 0,1; -fx-padding: 50;" text="How do I play this game?" />
</children>
</Pane>
</children>

Loading…
Cancel
Save