Made changes based on DoD review. Class documentation and commenting added. Removed annotation features. Removed sout commands. #story[1189]

main
zwu18 8 years ago
parent 5e35cd4195
commit fc9a4898d6

@ -122,9 +122,11 @@ public class RaceController extends Controller {
try {
controlKey.onAction(); // Change key state if applicable
//Check if current race is a tutorial
if (isTutorial){
//Check if current tutorial state has the same boat protocol code as key press
if (controlKey.getProtocolCode().equals(currentState.getAction())){
//Update tutorial
checkTutorialState();
}
}
@ -259,9 +261,12 @@ public class RaceController extends Controller {
if(key != null) {
switch (key.toString()) {
case "Zoom In":
//Check if race is a tutorial
if (isTutorial) {
//Check if the current tutorial state is zoom-in
if (currentState.equals(TutorialState.ZOOMIN)) {
try {
//Update tutorial
checkTutorialState();
} catch (Exception e1) {
e1.printStackTrace();
@ -271,9 +276,12 @@ public class RaceController extends Controller {
view3D.updateDistance(-10);
break;
case "Zoom Out":
//Check if race is a tutorial
if(isTutorial) {
//Check if current tutorial state is zoom-out
if (currentState.equals(TutorialState.ZOOMOUT)) {
try {
//Update tutorial
checkTutorialState();
} catch (Exception e1) {
e1.printStackTrace();
@ -586,6 +594,7 @@ public class RaceController extends Controller {
* Get the next tutorial state
*/
private void updateTutorialState(){
//Next tutorial state is popped from list
currentState = tutorialStates.get(0);
tutorialStates.remove(0);
}
@ -595,8 +604,11 @@ public class RaceController extends Controller {
* @param command the command of the key
*/
private void searchMapForKey(String command){
//For loop through keyFactory
for (Map.Entry<String, ControlKey> entry: keyFactory.getKeyState().entrySet()){
if(entry.getValue().toString().equals(command)){
//Found next key required to press
keyToPress = entry.getKey();
}
}
@ -607,43 +619,59 @@ public class RaceController extends Controller {
* @throws Exception Exception thrown
*/
private void checkTutorialState() throws Exception {
//Switch statement to check what the current tutorial state is
switch (currentState){
case UPWIND:
//Set next key to press as the downwind key
searchMapForKey("Downwind");
//Update tutorial text
tutorialText.setText("Nice! To turn downwind press " + keyToPress + ".");
updateTutorialState();
break;
case DOWNWIND:
//Set next key to press as the tack/gybe key
searchMapForKey("Tack/Gybe");
//Update tutorial text
tutorialText.setText("Nice! To tack or gybe press " + keyToPress + ".");
updateTutorialState();
break;
case TACKGYBE:
//Set next key to press as the VMG key
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();
break;
case VMG:
//Set next key to press as the sails-in key
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();
break;
case SAILSIN:
//Set next key to press as the sails-out key
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();
break;
case SAILSOUT:
//Set next key to press as the zoom-in key
searchMapForKey("Zoom In");
//Update tutorial text
tutorialText.setText("Nice! To zoom in press " + keyToPress + ".");
updateTutorialState();
break;
case ZOOMIN:
//Set next key to press as the zoom-out key
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();
break;
case ZOOMOUT:
//Finished tutorial. Display pop-up for exiting the tutorial
tutorialText.setText("Congratulations! You're done!");
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Finished Tutorial");
@ -657,7 +685,10 @@ public class RaceController extends Controller {
}
break;
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;
}

@ -215,8 +215,6 @@ public class StartController extends Controller {
* Countdown timer until race starts.
*/
private void countdownTimer() {
System.out.println(parent.getGameType());
new AnimationTimer() {
@Override
public void handle(long arg0) {

@ -140,7 +140,6 @@ public class TitleController extends Controller {
public void tutorialStartPressed() throws IOException {
titleWrapper.setVisible(false);
System.out.println("Start the tutorial!");
parent.setGameType(4);
parent.beginGame();

@ -9,20 +9,10 @@ import static visualiser.app.App.keyFactory;
import java.util.ArrayList;
/**
* Created by zwu18 on 10/09/17.
* State of which stage the tutorial is currently in
*/
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
*/
@ -53,12 +43,16 @@ public enum TutorialState {
*/
SAILSOUT(BoatActionEnum.SAILS_OUT),
/**
* State for zoom-in in tutorial
*/
ZOOMIN(null),
/**
* State for zoom-out in tutorial
*/
ZOOMOUT(null);
private BoatActionEnum action;
TutorialState(BoatActionEnum action){

@ -28,7 +28,7 @@
<?import javafx.scene.layout.StackPane?>
<?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>
<StackPane fx:id="newPane" prefHeight="150.0" prefWidth="200.0">
<children>
@ -42,7 +42,7 @@
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
<Pane prefHeight="200.0" prefWidth="400.0">
<Pane prefHeight="200.0" prefWidth="400.0" visible="false">
<children>
<Accordion>
<panes>

Loading…
Cancel
Save