Fixed the issue where the ship shot with no guns
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import javafx.animation.*;
|
import javafx.animation.*;
|
||||||
|
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
@@ -322,11 +321,17 @@ public class AnimationTesting extends Player {
|
|||||||
if(getGuns()>0) {
|
if(getGuns()>0) {
|
||||||
shotsFired.setCycleCount(getGuns());
|
shotsFired.setCycleCount(getGuns());
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
shotsFired.setCycleCount(0);
|
||||||
|
shotsFired.stop();
|
||||||
|
cannon.setVisible(false);
|
||||||
|
}
|
||||||
shotsFired.setNode(cannon);
|
shotsFired.setNode(cannon);
|
||||||
shotsFired.play();
|
shotsFired.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shipsRetaliate(){
|
public void shipsRetaliate(){
|
||||||
|
cannon.setVisible(true);
|
||||||
enemyShots.setFromX(270);
|
enemyShots.setFromX(270);
|
||||||
enemyShots.setFromY(0);
|
enemyShots.setFromY(0);
|
||||||
enemyShots.setToX(-30);
|
enemyShots.setToX(-30);
|
||||||
@@ -568,7 +573,7 @@ public class AnimationTesting extends Player {
|
|||||||
runButton.setVisible(false);
|
runButton.setVisible(false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
winOrLose= destroyLittyShipsOrEscape(primaryStage);
|
winOrLose= destroyLittyShipsOrEscape(primaryStage);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -585,7 +590,7 @@ public class AnimationTesting extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
playerShoots();
|
playerShoots();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -593,50 +598,46 @@ public class AnimationTesting extends Player {
|
|||||||
shotsFired.setOnFinished(new EventHandler<ActionEvent>() {
|
shotsFired.setOnFinished(new EventHandler<ActionEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
|
shotsFired.stop();
|
||||||
|
if(!winOrLose) {
|
||||||
|
shipsRetaliate();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
report.setVisible(true);
|
||||||
|
continueButton.setVisible(true);
|
||||||
|
usAgainstEnemyDivisor.setVisible(false);
|
||||||
|
cannon.setVisible(false);
|
||||||
shotsFired.stop();
|
shotsFired.stop();
|
||||||
if(!winOrLose) {
|
|
||||||
shipsRetaliate();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
report.setVisible(true);
|
|
||||||
continueButton.setVisible(true);
|
|
||||||
usAgainstEnemyDivisor.setVisible(false);
|
|
||||||
cannon.setVisible(false);
|
|
||||||
shotsFired.stop();
|
|
||||||
|
|
||||||
}
|
|
||||||
enemyShots.setOnFinished(new EventHandler<ActionEvent>() {
|
|
||||||
@Override
|
|
||||||
public void handle(ActionEvent event) {
|
|
||||||
fightButton.setVisible(true);
|
|
||||||
runButton.setVisible(true);
|
|
||||||
report.setVisible(true);
|
|
||||||
cannon.setVisible(false);
|
|
||||||
runAwayOrLeft.setVisible(true);
|
|
||||||
gunsLeftOrTaken.setVisible(true);
|
|
||||||
shipsRemaining.setVisible(true);
|
|
||||||
HPLeft.setVisible(true);
|
|
||||||
gunsLeftOrTaken.setVisible(true);
|
|
||||||
|
|
||||||
if(winOrLose==true){
|
|
||||||
usAgainstEnemyDivisor.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
enemyShots.setOnFinished(new EventHandler<ActionEvent>() {
|
||||||
|
@Override
|
||||||
|
public void handle(ActionEvent event) {
|
||||||
|
fightButton.setVisible(true);
|
||||||
|
runButton.setVisible(true);
|
||||||
|
report.setVisible(true);
|
||||||
|
cannon.setVisible(false);
|
||||||
|
runAwayOrLeft.setVisible(true);
|
||||||
|
gunsLeftOrTaken.setVisible(true);
|
||||||
|
shipsRemaining.setVisible(true);
|
||||||
|
HPLeft.setVisible(true);
|
||||||
|
gunsLeftOrTaken.setVisible(true);
|
||||||
|
|
||||||
});
|
if(winOrLose==true){
|
||||||
|
usAgainstEnemyDivisor.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,100 +645,3 @@ public class AnimationTesting extends Player {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
cannon.setLayoutX(beginningX);
|
|
||||||
cannon.setLayoutY(beginningY);
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(Event event) {
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
if (i == 2) {
|
|
||||||
shotsFired.setFromX(0);
|
|
||||||
shotsFired.setFromY(0);
|
|
||||||
shotsFired.setToX(endX + 60);
|
|
||||||
shotsFired.setToY(endY + 70);
|
|
||||||
|
|
||||||
shotsFired.setFromX(0);
|
|
||||||
shotsFired.setFromY(0);
|
|
||||||
shotsFired.setToX(endX);
|
|
||||||
shotsFired.setToY(endY);
|
|
||||||
shotsFired.setNode(cannon);
|
|
||||||
shotsFired.play();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
shotsFired.setFromX(0);
|
|
||||||
shotsFired.setFromY(0);
|
|
||||||
shotsFired.setToX(endX );
|
|
||||||
shotsFired.setToY(endY );
|
|
||||||
|
|
||||||
shotsFired.setFromX(0);
|
|
||||||
shotsFired.setFromY(0);
|
|
||||||
shotsFired.setToX(endX);
|
|
||||||
shotsFired.setToY(endY);
|
|
||||||
shotsFired.setNode(cannon);
|
|
||||||
shotsFired.get
|
|
||||||
shotsFired.play();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
shotsFired.setDuration(Duration.seconds(3));
|
|
||||||
shotsFired.setCycleCount(5);
|
|
||||||
|
|
||||||
|
|
||||||
shotsFired.play();
|
|
||||||
|
|
||||||
|
|
||||||
shotsFired.setOnFinished(new EventHandler<ActionEvent>() {
|
|
||||||
@Override
|
|
||||||
|
|
||||||
public void handle(ActionEvent event) {
|
|
||||||
shotsFired.stop();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
destroyLittyShipsOrEscape(primaryStage);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (counter >= 1) {
|
|
||||||
title.setVisible(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Scene scene = new Scene(root, 600, 480);
|
|
||||||
root.getStylesheets().add("styleguide.css");
|
|
||||||
|
|
||||||
primaryStage.setResizable(false);
|
|
||||||
|
|
||||||
primaryStage.setScene(scene);
|
|
||||||
primaryStage.show();
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user