Playing with miss animation

This commit is contained in:
KahootChampion
2019-03-29 08:20:56 -06:00
parent 02efa7a9ba
commit 61ba606e89
3 changed files with 147 additions and 138 deletions

186
.idea/workspace.xml generated
View File

@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3114a2b9-4919-4fdf-8fd9-d03b60109ce4" name="Default Changelist" comment="Completed ShipWarfareGUI"> <list default="true" id="3114a2b9-4919-4fdf-8fd9-d03b60109ce4" name="Default Changelist" comment="Fixed an issue with shipWarfare with the ships running away label">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ShipWarfareGUI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ShipWarfareGUI.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/saves/playerSave.txt" beforeDir="false" afterPath="$PROJECT_DIR$/src/saves/playerSave.txt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/saves/playerSave.txt" beforeDir="false" afterPath="$PROJECT_DIR$/src/saves/playerSave.txt" afterDir="false" />
</list> </list>
<ignored path="$PROJECT_DIR$/out/" /> <ignored path="$PROJECT_DIR$/out/" />
@@ -16,35 +17,11 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/ShipWarfareGUI.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1380">
<caret line="341" column="35" lean-forward="true" selection-start-line="341" selection-start-column="35" selection-end-line="341" selection-end-column="35" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/TaipanShopGUI.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="291">
<caret line="277" column="43" selection-start-line="277" selection-start-column="43" selection-end-line="277" selection-end-column="43" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/MainGUI.java"> <entry file="file://$PROJECT_DIR$/src/MainGUI.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="356"> <state relative-caret-position="315">
<caret line="28" selection-start-line="18" selection-start-column="4" selection-end-line="28" /> <caret line="24" column="41" selection-start-line="24" selection-start-column="41" selection-end-line="24" selection-end-column="41" />
<folding> <folding>
<element signature="e#551#552#0" expanded="true" /> <element signature="e#551#552#0" expanded="true" />
<element signature="e#579#580#0" expanded="true" /> <element signature="e#579#580#0" expanded="true" />
@@ -53,20 +30,14 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/GameEndGUI.java"> <entry file="file://$PROJECT_DIR$/src/ShipWarfareGUI.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="750"> <state relative-caret-position="322">
<caret line="56" column="24" selection-start-line="56" selection-start-column="24" selection-end-line="56" selection-end-column="24" /> <caret line="589" column="27" selection-start-line="589" selection-start-column="27" selection-end-line="589" selection-end-column="27" />
</state> <folding>
</provider> <element signature="imports" expanded="true" />
</entry> </folding>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/TravelGUI.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="313">
<caret line="188" column="11" selection-start-line="188" selection-start-column="11" selection-end-line="188" selection-end-column="11" />
</state> </state>
</provider> </provider>
</entry> </entry>
@@ -83,12 +54,6 @@
</component> </component>
<component name="FindInProjectRecents"> <component name="FindInProjectRecents">
<findStrings> <findStrings>
<find>.setvis</find>
<find>durati</find>
<find>setText</find>
<find>setVisi</find>
<find>continue</find>
<find>userSh</find>
<find>continueButton</find> <find>continueButton</find>
<find>continueButton.setV</find> <find>continueButton.setV</find>
<find>.setText</find> <find>.setText</find>
@@ -104,15 +69,21 @@
<find>runFrom</find> <find>runFrom</find>
<find>report</find> <find>report</find>
<find>report.setVisible</find> <find>report.setVisible</find>
<find>playerSh</find>
<find>fightButton</find> <find>fightButton</find>
<find>PlayerSh</find> <find>PlayerSh</find>
<find>andT</find> <find>andT</find>
<find>dest</find> <find>dest</find>
<find>playerShoots</find>
<find>shotsFired</find> <find>shotsFired</find>
<find>duration</find> <find>duration</find>
<find>shop()</find> <find>shop()</find>
<find>dang i</find>
<find>playerS</find>
<find>cowards</find>
<find>playerShoots</find>
<find>playerSh</find>
<find>getGuns</find>
<find>!</find>
<find>earned</find>
</findStrings> </findStrings>
<replaceStrings> <replaceStrings>
<replace>HP</replace> <replace>HP</replace>
@@ -150,8 +121,8 @@
<option value="$PROJECT_DIR$/src/Player.java" /> <option value="$PROJECT_DIR$/src/Player.java" />
<option value="$PROJECT_DIR$/src/AnimationTesting.java" /> <option value="$PROJECT_DIR$/src/AnimationTesting.java" />
<option value="$PROJECT_DIR$/src/TravelGUI.java" /> <option value="$PROJECT_DIR$/src/TravelGUI.java" />
<option value="$PROJECT_DIR$/src/ShipWarfareGUI.java" />
<option value="$PROJECT_DIR$/src/TaipanShopGUI.java" /> <option value="$PROJECT_DIR$/src/TaipanShopGUI.java" />
<option value="$PROJECT_DIR$/src/ShipWarfareGUI.java" />
</list> </list>
</option> </option>
</component> </component>
@@ -188,15 +159,15 @@
<select /> <select />
</subPane> </subPane>
</pane> </pane>
<pane id="PackagesPane" />
<pane id="Scope" /> <pane id="Scope" />
<pane id="PackagesPane" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="ChangesTree.GroupingKeys" value="" /> <property name="ChangesTree.GroupingKeys" value="" />
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" /> <property name="aspect.path.notification.shown" value="true" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1553533565975" /> <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1553647592854" />
<property name="extract.method.default.visibility" value="public" /> <property name="extract.method.default.visibility" value="public" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../GitHub/Cpsc233" /> <property name="last_opened_file_path" value="$PROJECT_DIR$/../GitHub/Cpsc233" />
<property name="project.structure.last.edited" value="Modules" /> <property name="project.structure.last.edited" value="Modules" />
@@ -261,7 +232,6 @@
<list> <list>
<item itemvalue="Application.TaipanShop" /> <item itemvalue="Application.TaipanShop" />
<item itemvalue="Application.main" /> <item itemvalue="Application.main" />
<item itemvalue="Application.ShipWarfareGUI" />
<item itemvalue="Application.MainGUI" /> <item itemvalue="Application.MainGUI" />
<item itemvalue="Application.ShipWarfareGUI" /> <item itemvalue="Application.ShipWarfareGUI" />
</list> </list>
@@ -336,28 +306,9 @@
<workItem from="1553387530005" duration="22322000" /> <workItem from="1553387530005" duration="22322000" />
<workItem from="1553444493182" duration="159000" /> <workItem from="1553444493182" duration="159000" />
<workItem from="1553444769737" duration="82000" /> <workItem from="1553444769737" duration="82000" />
<workItem from="1553444880371" duration="34292000" /> <workItem from="1553444880371" duration="36052000" />
</task> <workItem from="1553560570410" duration="3016000" />
<task id="LOCAL-00009" summary="Fixed a bunch of stuff inside of Travel, but also discovered a MASSIVE problem with our code"> <workItem from="1553832002953" duration="139000" />
<created>1550628232136</created>
<option name="number" value="00009" />
<option name="presentableId" value="LOCAL-00009" />
<option name="project" value="LOCAL" />
<updated>1550628232136</updated>
</task>
<task id="LOCAL-00010" summary="Brought back Vikram's changes">
<created>1550879092914</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1550879092914</updated>
</task>
<task id="LOCAL-00011" summary="Fixed the commenting on a lot of the code. Also added some stuff to Travel, fixed some bugs.">
<created>1551162699319</created>
<option name="number" value="00011" />
<option name="presentableId" value="LOCAL-00011" />
<option name="project" value="LOCAL" />
<updated>1551162699319</updated>
</task> </task>
<task id="LOCAL-00012" summary="Added time stuff to Shipwarfare GUI"> <task id="LOCAL-00012" summary="Added time stuff to Shipwarfare GUI">
<created>1552168801248</created> <created>1552168801248</created>
@@ -681,17 +632,38 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1553533396273</updated> <updated>1553533396273</updated>
</task> </task>
<option name="localTasksCounter" value="58" /> <task id="LOCAL-00058" summary="Completed ShipWarfareGUI">
<created>1553533600087</created>
<option name="number" value="00058" />
<option name="presentableId" value="LOCAL-00058" />
<option name="project" value="LOCAL" />
<updated>1553533600087</updated>
</task>
<task id="LOCAL-00059" summary="Ship Warfare &quot;dang it&quot; issue fixed">
<created>1553542511809</created>
<option name="number" value="00059" />
<option name="presentableId" value="LOCAL-00059" />
<option name="project" value="LOCAL" />
<updated>1553542511809</updated>
</task>
<task id="LOCAL-00060" summary="Fixed an issue with ShipWarfareGUI with the ships running away label">
<created>1553560337526</created>
<option name="number" value="00060" />
<option name="presentableId" value="LOCAL-00060" />
<option name="project" value="LOCAL" />
<updated>1553560337526</updated>
</task>
<option name="localTasksCounter" value="61" />
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="164961000" /> <option name="totallyTimeSpent" value="169876000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="0" y="23" width="1189" height="652" extended-state="0" /> <frame x="0" y="23" width="1189" height="652" extended-state="0" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.2205754" /> <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.22755013" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Image Layers" order="2" /> <window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" /> <window_info id="Designer" order="3" />
@@ -700,7 +672,7 @@
<window_info id="Favorites" order="6" side_tool="true" /> <window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32922733" /> <window_info anchor="bottom" id="Find" order="1" weight="0.32922733" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.22678572" /> <window_info anchor="bottom" id="Run" order="2" weight="0.22678572" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" /> <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -788,9 +760,6 @@
<ignored-roots> <ignored-roots>
<path value="$PROJECT_DIR$" /> <path value="$PROJECT_DIR$" />
</ignored-roots> </ignored-roots>
<MESSAGE value="Completed SHipWarfareGUI" />
<MESSAGE value="Probably should upload" />
<MESSAGE value="Fixed ShipWarfare bug about one-shotting." />
<MESSAGE value="Completed javadocs for shipwarfare GUI" /> <MESSAGE value="Completed javadocs for shipwarfare GUI" />
<MESSAGE value="Added to my javadocs a bit" /> <MESSAGE value="Added to my javadocs a bit" />
<MESSAGE value="Changed one line of text in shipwarfare GUI" /> <MESSAGE value="Changed one line of text in shipwarfare GUI" />
@@ -811,9 +780,12 @@
<MESSAGE value="Small error in animation whcih shoots even if no guns must fix that" /> <MESSAGE value="Small error in animation whcih shoots even if no guns must fix that" />
<MESSAGE value="Fixed the issue where the ship shot with no guns" /> <MESSAGE value="Fixed the issue where the ship shot with no guns" />
<MESSAGE value="ShipWarfare javaDocs completed" /> <MESSAGE value="ShipWarfare javaDocs completed" />
<MESSAGE value="Completed ShipWarfareGUI" />
<MESSAGE value="Fixed silk issue" /> <MESSAGE value="Fixed silk issue" />
<option name="LAST_COMMIT_MESSAGE" value="Fixed silk issue" /> <MESSAGE value="Completed ShipWarfareGUI" />
<MESSAGE value="Ship Warfare &quot;dang it&quot; issue fixed" />
<MESSAGE value="Fixed an issue with shipWarfare with the ships running away label" />
<MESSAGE value="Fixed an issue with ShipWarfareGUI with the ships running away label" />
<option name="LAST_COMMIT_MESSAGE" value="Fixed an issue with ShipWarfareGUI with the ships running away label" />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="uml://JAVA/ShipWarfare"> <entry file="uml://JAVA/ShipWarfare">
@@ -928,6 +900,16 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/PlayerTest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="41">
<caret line="18" column="71" selection-start-line="18" selection-start-column="71" selection-end-line="18" selection-end-column="71" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/GameEndGUI.java"> <entry file="file://$PROJECT_DIR$/src/GameEndGUI.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="750"> <state relative-caret-position="750">
@@ -935,30 +917,9 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/MainGUI.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="356">
<caret line="28" selection-start-line="18" selection-start-column="4" selection-end-line="28" />
<folding>
<element signature="e#551#552#0" expanded="true" />
<element signature="e#579#580#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ShipWarfareGUI.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="104">
<caret line="156" column="7" lean-forward="true" selection-start-line="152" selection-start-column="4" selection-end-line="156" selection-end-column="7" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/TravelGUI.java"> <entry file="file://$PROJECT_DIR$/src/TravelGUI.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="313"> <state relative-caret-position="2550">
<caret line="188" column="11" selection-start-line="188" selection-start-column="11" selection-end-line="188" selection-end-column="11" /> <caret line="188" column="11" selection-start-line="188" selection-start-column="11" selection-end-line="188" selection-end-column="11" />
</state> </state>
</provider> </provider>
@@ -973,10 +934,21 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/MainGUI.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="315">
<caret line="24" column="41" selection-start-line="24" selection-start-column="41" selection-end-line="24" selection-end-column="41" />
<folding>
<element signature="e#551#552#0" expanded="true" />
<element signature="e#579#580#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ShipWarfareGUI.java"> <entry file="file://$PROJECT_DIR$/src/ShipWarfareGUI.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1380"> <state relative-caret-position="322">
<caret line="341" column="35" lean-forward="true" selection-start-line="341" selection-start-column="35" selection-end-line="341" selection-end-column="35" /> <caret line="589" column="27" selection-start-line="589" selection-start-column="27" selection-end-line="589" selection-end-column="27" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>

View File

@@ -14,6 +14,7 @@ import javafx.scene.layout.VBox;
import javafx.scene.shape.Circle; import javafx.scene.shape.Circle;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.util.Duration; import javafx.util.Duration;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@@ -42,7 +43,7 @@ public class ShipWarfareGUI extends Player {
private Label shipsRemaining; private Label shipsRemaining;
private Label report; private Label report;
private boolean winOrLose= false; private boolean winOrLose = false;
private int counter1; private int counter1;
@@ -55,6 +56,9 @@ public class ShipWarfareGUI extends Player {
private int counter = 0; private int counter = 0;
private String pirateName = "Liu Yen"; private String pirateName = "Liu Yen";
private int missCounter;
private int hitCounter;
private int beginningX = 150; private int beginningX = 150;
private int beginningY = 245; private int beginningY = 245;
@@ -62,6 +66,8 @@ public class ShipWarfareGUI extends Player {
private int endY = 90; private int endY = 90;
private TranslateTransition shotsFired = new TranslateTransition(); private TranslateTransition shotsFired = new TranslateTransition();
private TranslateTransition shotsMissed = new TranslateTransition();
private TranslateTransition enemyShots = new TranslateTransition(); private TranslateTransition enemyShots = new TranslateTransition();
/** /**
@@ -159,8 +165,6 @@ public class ShipWarfareGUI extends Player {
} }
/** /**
* The user faces off against the litty ships and either prevails, dies, or runs away * The user faces off against the litty ships and either prevails, dies, or runs away
* *
@@ -171,14 +175,11 @@ public class ShipWarfareGUI extends Player {
cannon.setLayoutY(beginningY); cannon.setLayoutY(beginningY);
int calculateLoot = 0; int calculateLoot = 0;
int chanceOfEnemyRun = 0; int chanceOfEnemyRun = 0;
int hitCounter = 0; hitCounter = 0;
int missCounter = 0; missCounter = 0;
boolean gunFrustration = false; boolean gunFrustration = false;
runAwayOrLeft.setText("No ships ran away"); runAwayOrLeft.setText("No ships ran away");
Random randomValue = new Random(); Random randomValue = new Random();
int exitValue = 0; int exitValue = 0;
@@ -205,7 +206,6 @@ public class ShipWarfareGUI extends Player {
} }
} else { } else {
//continue; //continue;
} }
@@ -266,7 +266,6 @@ public class ShipWarfareGUI extends Player {
} }
if (gunFrustration == true) { if (gunFrustration == true) {
gunsLeftOrTaken.setText(String.format("Dang it! We only have %d guns left", getGuns())); gunsLeftOrTaken.setText(String.format("Dang it! We only have %d guns left", getGuns()));
playerShoots(getGuns()+1);
} else { } else {
gunsLeftOrTaken.setText(String.format("We still have %d guns left", getGuns())); gunsLeftOrTaken.setText(String.format("We still have %d guns left", getGuns()));
@@ -312,29 +311,41 @@ public class ShipWarfareGUI extends Player {
* Player attacks enemy ships in an animation * Player attacks enemy ships in an animation
*/ */
public void playerShoots(int amountOfShots) { public void playerShoots(int amountOfShots) {
userAttacks=true; userAttacks = true;
shotsFired.setFromX(0); shotsFired.setFromX(0);
shotsFired.setFromY(0); shotsFired.setFromY(0);
shotsFired.setToX(endX); shotsFired.setToX(endX);
shotsFired.setToY(endY); shotsFired.setToY(endY);
shotsFired.setDuration(Duration.seconds(0.5)); shots(amountOfShots, shotsFired);
if(getGuns()>0) {
shotsFired.setCycleCount(amountOfShots);
} }
else{
shotsFired.setCycleCount(0); public void playerMisses(int amountOfShots) {
shotsFired.stop(); userAttacks = true;
shotsMissed.setFromX(0);
shotsMissed.setFromY(0);
shotsMissed.setToX(endX + 90);
shotsMissed.setToY(endY + 90);
shots(amountOfShots, shotsMissed);
}
public void shots(int amountOfShots, TranslateTransition shots) {
shots.setDuration(Duration.seconds(0.5));
if (getGuns() > 0) {
shots.setCycleCount(amountOfShots);
} else {
shots.setCycleCount(0);
shots.stop();
cannon.setVisible(false); cannon.setVisible(false);
} }
shotsFired.setNode(cannon); shots.setNode(cannon);
shotsFired.play(); shots.play();
} }
/** /**
* Ships attack player ship back in an animation * Ships attack player ship back in an animation
*/ */
public void shipsRetaliate(){ public void shipsRetaliate() {
cannon.setVisible(true); cannon.setVisible(true);
enemyShots.setFromX(270); enemyShots.setFromX(270);
enemyShots.setFromY(0); enemyShots.setFromY(0);
@@ -371,6 +382,7 @@ public class ShipWarfareGUI extends Player {
/** /**
* Generaties ships and deploys logic for the shipwarfare * Generaties ships and deploys logic for the shipwarfare
*
* @param primaryStage sets up the stage to whcih the GUI may be based around * @param primaryStage sets up the stage to whcih the GUI may be based around
* @throws Exception in case of interruptions withing the graphical interface * @throws Exception in case of interruptions withing the graphical interface
*/ */
@@ -388,7 +400,6 @@ public class ShipWarfareGUI extends Player {
this.cannon = cannon; this.cannon = cannon;
cannon.setVisible(false); cannon.setVisible(false);
buttonBox = new VBox(); buttonBox = new VBox();
@@ -455,7 +466,7 @@ public class ShipWarfareGUI extends Player {
ourShip = new Image(new FileInputStream("src/images/ourShip.png")); ourShip = new Image(new FileInputStream("src/images/ourShip.png"));
enemyShip = new Image(new FileInputStream("src/images/enemyShip.png")); enemyShip = new Image(new FileInputStream("src/images/enemyShip.png"));
}catch(Exception e){ } catch (Exception e) {
ourShip = new Image(new FileInputStream("images/ourShip.png")); ourShip = new Image(new FileInputStream("images/ourShip.png"));
enemyShip = new Image(new FileInputStream("images/enemyShip.png")); enemyShip = new Image(new FileInputStream("images/enemyShip.png"));
} }
@@ -563,11 +574,11 @@ public class ShipWarfareGUI extends Player {
if (runFromShips() == false) { if (runFromShips() == false) {
report.setText(("Couldn't run away")); report.setText(("Couldn't run away"));
try { try {
winOrLose= destroyLittyShipsOrEscape(primaryStage); winOrLose = destroyLittyShipsOrEscape(primaryStage);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if(winOrLose==true){ if (winOrLose == true) {
report.setVisible(true); report.setVisible(true);
title.setVisible(true); title.setVisible(true);
shipsRemaining.setVisible(true); shipsRemaining.setVisible(true);
@@ -603,7 +614,7 @@ public class ShipWarfareGUI 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();
} }
@@ -619,9 +630,36 @@ public class ShipWarfareGUI extends Player {
} }
playerShoots(getGuns()); if(hitCounter!=0) {
if(winOrLose==true){
playerShoots(numOfLittyShips);
}
else {
playerShoots(hitCounter);
}
}
else{
playerMisses(hitCounter);
}
shotsFired.setOnFinished(new EventHandler<ActionEvent>() { shotsFired.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
playerMisses(missCounter);
} catch (Exception e) {
e.printStackTrace();
}
}
});
shotsMissed.setOnFinished(new EventHandler<ActionEvent>() {
@Override @Override
/** /**
* When the user is completed their volley this information will be accessed * When the user is completed their volley this information will be accessed
@@ -629,10 +667,9 @@ public class ShipWarfareGUI extends Player {
*/ */
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
shotsFired.stop(); shotsFired.stop();
if(!winOrLose) { if (!winOrLose) {
shipsRetaliate(); shipsRetaliate();
} } else {
else{
report.setVisible(true); report.setVisible(true);
continueButton.setVisible(true); continueButton.setVisible(true);
usAgainstEnemyDivisor.setVisible(false); usAgainstEnemyDivisor.setVisible(false);
@@ -657,7 +694,7 @@ public class ShipWarfareGUI extends Player {
HPLeft.setVisible(true); HPLeft.setVisible(true);
gunsLeftOrTaken.setVisible(true); gunsLeftOrTaken.setVisible(true);
if(winOrLose==true){ if (winOrLose == true) {
usAgainstEnemyDivisor.setVisible(false); usAgainstEnemyDivisor.setVisible(false);
} }

Binary file not shown.