Made changes based on DoD review. Class documentation and commenting added. Removed annotation features. Removed sout commands. #story[1189]
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -215,8 +215,6 @@ 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) {
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ 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!");
|
|
||||||
parent.setGameType(4);
|
parent.setGameType(4);
|
||||||
parent.beginGame();
|
parent.beginGame();
|
||||||
|
|
||||||
|
|||||||
@@ -9,20 +9,10 @@ import static visualiser.app.App.keyFactory;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by zwu18 on 10/09/17.
|
* State of which stage the tutorial is currently in
|
||||||
*/
|
*/
|
||||||
public enum TutorialState {
|
public enum TutorialState {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// keyState.put("Z", new ZoomInKey());
|
|
||||||
// keyState.put("X", new ZoomOutKey());
|
|
||||||
// keyState.put("SPACE", new VMGKey());
|
|
||||||
// keyState.put("SHIFT", new SailsToggleKey());
|
|
||||||
// keyState.put("ENTER", new TackGybeKey());
|
|
||||||
// keyState.put("UP", new UpWindKey());
|
|
||||||
// keyState.put("DOWN", new DownWindKey());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State for upwind in tutorial
|
* State for upwind in tutorial
|
||||||
*/
|
*/
|
||||||
@@ -53,12 +43,16 @@ public enum TutorialState {
|
|||||||
*/
|
*/
|
||||||
SAILSOUT(BoatActionEnum.SAILS_OUT),
|
SAILSOUT(BoatActionEnum.SAILS_OUT),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* State for zoom-in in tutorial
|
||||||
|
*/
|
||||||
ZOOMIN(null),
|
ZOOMIN(null),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* State for zoom-out in tutorial
|
||||||
|
*/
|
||||||
ZOOMOUT(null);
|
ZOOMOUT(null);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private BoatActionEnum action;
|
private BoatActionEnum action;
|
||||||
|
|
||||||
TutorialState(BoatActionEnum action){
|
TutorialState(BoatActionEnum action){
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<?import javafx.scene.layout.StackPane?>
|
<?import javafx.scene.layout.StackPane?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<SplitPane fx:id="racePane" dividerPositions="1.0" prefHeight="431.0" prefWidth="610.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceController">
|
<SplitPane fx:id="racePane" dividerPositions="1.0" prefHeight="431.0" prefWidth="610.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceController">
|
||||||
<items>
|
<items>
|
||||||
<StackPane fx:id="newPane" prefHeight="150.0" prefWidth="200.0">
|
<StackPane fx:id="newPane" prefHeight="150.0" prefWidth="200.0">
|
||||||
<children>
|
<children>
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
<Pane prefHeight="200.0" prefWidth="400.0">
|
<Pane prefHeight="200.0" prefWidth="400.0" visible="false">
|
||||||
<children>
|
<children>
|
||||||
<Accordion>
|
<Accordion>
|
||||||
<panes>
|
<panes>
|
||||||
|
|||||||
Reference in New Issue
Block a user