|
|
|
@ -122,9 +122,11 @@ public class RaceController extends Controller {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
controlKey.onAction(); // Change key state if applicable
|
|
|
|
controlKey.onAction(); // Change key state if applicable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Check if current race is a tutorial
|
|
|
|
if (isTutorial){
|
|
|
|
if (isTutorial){
|
|
|
|
|
|
|
|
//Check if current tutorial state has the same boat protocol code as key press
|
|
|
|
if (controlKey.getProtocolCode().equals(currentState.getAction())){
|
|
|
|
if (controlKey.getProtocolCode().equals(currentState.getAction())){
|
|
|
|
|
|
|
|
//Update tutorial
|
|
|
|
checkTutorialState();
|
|
|
|
checkTutorialState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -259,9 +261,12 @@ public class RaceController extends Controller {
|
|
|
|
if(key != null) {
|
|
|
|
if(key != null) {
|
|
|
|
switch (key.toString()) {
|
|
|
|
switch (key.toString()) {
|
|
|
|
case "Zoom In":
|
|
|
|
case "Zoom In":
|
|
|
|
|
|
|
|
//Check if race is a tutorial
|
|
|
|
if (isTutorial) {
|
|
|
|
if (isTutorial) {
|
|
|
|
|
|
|
|
//Check if the current tutorial state is zoom-in
|
|
|
|
if (currentState.equals(TutorialState.ZOOMIN)) {
|
|
|
|
if (currentState.equals(TutorialState.ZOOMIN)) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
//Update tutorial
|
|
|
|
checkTutorialState();
|
|
|
|
checkTutorialState();
|
|
|
|
} catch (Exception e1) {
|
|
|
|
} catch (Exception e1) {
|
|
|
|
e1.printStackTrace();
|
|
|
|
e1.printStackTrace();
|
|
|
|
@ -271,9 +276,12 @@ public class RaceController extends Controller {
|
|
|
|
view3D.updateDistance(-10);
|
|
|
|
view3D.updateDistance(-10);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "Zoom Out":
|
|
|
|
case "Zoom Out":
|
|
|
|
|
|
|
|
//Check if race is a tutorial
|
|
|
|
if(isTutorial) {
|
|
|
|
if(isTutorial) {
|
|
|
|
|
|
|
|
//Check if current tutorial state is zoom-out
|
|
|
|
if (currentState.equals(TutorialState.ZOOMOUT)) {
|
|
|
|
if (currentState.equals(TutorialState.ZOOMOUT)) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
//Update tutorial
|
|
|
|
checkTutorialState();
|
|
|
|
checkTutorialState();
|
|
|
|
} catch (Exception e1) {
|
|
|
|
} catch (Exception e1) {
|
|
|
|
e1.printStackTrace();
|
|
|
|
e1.printStackTrace();
|
|
|
|
@ -586,6 +594,7 @@ public class RaceController extends Controller {
|
|
|
|
* Get the next tutorial state
|
|
|
|
* Get the next tutorial state
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void updateTutorialState(){
|
|
|
|
private void updateTutorialState(){
|
|
|
|
|
|
|
|
//Next tutorial state is popped from list
|
|
|
|
currentState = tutorialStates.get(0);
|
|
|
|
currentState = tutorialStates.get(0);
|
|
|
|
tutorialStates.remove(0);
|
|
|
|
tutorialStates.remove(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -595,8 +604,11 @@ public class RaceController extends Controller {
|
|
|
|
* @param command the command of the key
|
|
|
|
* @param command the command of the key
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void searchMapForKey(String command){
|
|
|
|
private void searchMapForKey(String command){
|
|
|
|
|
|
|
|
//For loop through keyFactory
|
|
|
|
for (Map.Entry<String, ControlKey> entry: keyFactory.getKeyState().entrySet()){
|
|
|
|
for (Map.Entry<String, ControlKey> entry: keyFactory.getKeyState().entrySet()){
|
|
|
|
if(entry.getValue().toString().equals(command)){
|
|
|
|
if(entry.getValue().toString().equals(command)){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Found next key required to press
|
|
|
|
keyToPress = entry.getKey();
|
|
|
|
keyToPress = entry.getKey();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -607,43 +619,59 @@ public class RaceController extends Controller {
|
|
|
|
* @throws Exception Exception thrown
|
|
|
|
* @throws Exception Exception thrown
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void checkTutorialState() throws Exception {
|
|
|
|
private void checkTutorialState() throws Exception {
|
|
|
|
|
|
|
|
//Switch statement to check what the current tutorial state is
|
|
|
|
switch (currentState){
|
|
|
|
switch (currentState){
|
|
|
|
case UPWIND:
|
|
|
|
case UPWIND:
|
|
|
|
|
|
|
|
//Set next key to press as the downwind key
|
|
|
|
searchMapForKey("Downwind");
|
|
|
|
searchMapForKey("Downwind");
|
|
|
|
|
|
|
|
//Update tutorial text
|
|
|
|
tutorialText.setText("Nice! To turn downwind press " + keyToPress + ".");
|
|
|
|
tutorialText.setText("Nice! To turn downwind press " + keyToPress + ".");
|
|
|
|
updateTutorialState();
|
|
|
|
updateTutorialState();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DOWNWIND:
|
|
|
|
case DOWNWIND:
|
|
|
|
|
|
|
|
//Set next key to press as the tack/gybe key
|
|
|
|
searchMapForKey("Tack/Gybe");
|
|
|
|
searchMapForKey("Tack/Gybe");
|
|
|
|
|
|
|
|
//Update tutorial text
|
|
|
|
tutorialText.setText("Nice! To tack or gybe press " + keyToPress + ".");
|
|
|
|
tutorialText.setText("Nice! To tack or gybe press " + keyToPress + ".");
|
|
|
|
updateTutorialState();
|
|
|
|
updateTutorialState();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case TACKGYBE:
|
|
|
|
case TACKGYBE:
|
|
|
|
|
|
|
|
//Set next key to press as the VMG key
|
|
|
|
searchMapForKey("VMG");
|
|
|
|
searchMapForKey("VMG");
|
|
|
|
tutorialText.setText("Nice! To use VMG press " + keyToPress + ".");
|
|
|
|
//Update tutorial text
|
|
|
|
|
|
|
|
tutorialText.setText("Nice! To use VMG press " + keyToPress + ". This will turn the boat.");
|
|
|
|
updateTutorialState();
|
|
|
|
updateTutorialState();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case VMG:
|
|
|
|
case VMG:
|
|
|
|
|
|
|
|
//Set next key to press as the sails-in key
|
|
|
|
searchMapForKey("Toggle Sails");
|
|
|
|
searchMapForKey("Toggle Sails");
|
|
|
|
tutorialText.setText("Nice! To sails in press " + keyToPress + ".");
|
|
|
|
//Update tutorial text
|
|
|
|
|
|
|
|
tutorialText.setText("Nice! To sails in press " + keyToPress + ". This will stop the boat.");
|
|
|
|
updateTutorialState();
|
|
|
|
updateTutorialState();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SAILSIN:
|
|
|
|
case SAILSIN:
|
|
|
|
|
|
|
|
//Set next key to press as the sails-out key
|
|
|
|
searchMapForKey("Toggle Sails");
|
|
|
|
searchMapForKey("Toggle Sails");
|
|
|
|
tutorialText.setText("Nice! To sails out press " + keyToPress + " again.");
|
|
|
|
//Update tutorial text
|
|
|
|
|
|
|
|
tutorialText.setText("Nice! To sails out press " + keyToPress + " again. The will start moving again.");
|
|
|
|
updateTutorialState();
|
|
|
|
updateTutorialState();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SAILSOUT:
|
|
|
|
case SAILSOUT:
|
|
|
|
|
|
|
|
//Set next key to press as the zoom-in key
|
|
|
|
searchMapForKey("Zoom In");
|
|
|
|
searchMapForKey("Zoom In");
|
|
|
|
|
|
|
|
//Update tutorial text
|
|
|
|
tutorialText.setText("Nice! To zoom in press " + keyToPress + ".");
|
|
|
|
tutorialText.setText("Nice! To zoom in press " + keyToPress + ".");
|
|
|
|
updateTutorialState();
|
|
|
|
updateTutorialState();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case ZOOMIN:
|
|
|
|
case ZOOMIN:
|
|
|
|
|
|
|
|
//Set next key to press as the zoom-out key
|
|
|
|
searchMapForKey("Zoom Out");
|
|
|
|
searchMapForKey("Zoom Out");
|
|
|
|
tutorialText.setText("Nice! To zoom out press " + keyToPress + ".");
|
|
|
|
//Update tutorial text
|
|
|
|
|
|
|
|
tutorialText.setText("Nice! You will also be able to zoom into boats and marks by clicking them. To zoom out press " + keyToPress + ".");
|
|
|
|
updateTutorialState();
|
|
|
|
updateTutorialState();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case ZOOMOUT:
|
|
|
|
case ZOOMOUT:
|
|
|
|
|
|
|
|
//Finished tutorial. Display pop-up for exiting the tutorial
|
|
|
|
tutorialText.setText("Congratulations! You're done!");
|
|
|
|
tutorialText.setText("Congratulations! You're done!");
|
|
|
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
|
|
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
|
|
|
alert.setTitle("Finished Tutorial");
|
|
|
|
alert.setTitle("Finished Tutorial");
|
|
|
|
@ -657,7 +685,10 @@ public class RaceController extends Controller {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
System.out.println("Something went wrong.");
|
|
|
|
//State not found. Exit tutorial to title menu
|
|
|
|
|
|
|
|
parent.endEvent();
|
|
|
|
|
|
|
|
racePane.setVisible(false);
|
|
|
|
|
|
|
|
App.app.showMainStage(App.getStage());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|