diff --git a/src/main/java/event/Event01.java b/src/main/java/event/Event01.java index bf4147d..080963a 100644 --- a/src/main/java/event/Event01.java +++ b/src/main/java/event/Event01.java @@ -41,8 +41,8 @@ public void lookFlashlight() { gm.ui.messageText.setText("This is a flashlight"); } public void grabFlashlight() { - if(gm.player.hasFlashlight == 0) { - gm.player.hasFlashlight = 1; + if(!gm.player.hasFlashlight) { + gm.player.hasFlashlight = true; gm.ui.messageText.setText("(You obtained a flashlight)"); gm.player.updatePlayerStatus(); @@ -55,8 +55,8 @@ public void grabFlashlight() { } public void restFlashlight() { - if(gm.player.hasFlashlight == 1) { - gm.player.hasFlashlight = 0; + if(gm.player.hasFlashlight) { + gm.player.hasFlashlight = false; gm.ui.messageText.setText("*You rest the flashlight back on the bed*"); gm.player.updatePlayerStatus(); diff --git a/src/main/java/event/Event02.java b/src/main/java/event/Event02.java index ae445fb..15a38cc 100644 --- a/src/main/java/event/Event02.java +++ b/src/main/java/event/Event02.java @@ -7,15 +7,16 @@ public class Event02 { GameManager gm; public Event02(GameManager gm) { - this.gm = gm; } public void search1Honda() { gm.ui.messageText.setText("Nothing sus here"); } + public void search2Honda() { gm.ui.messageText.setText("OH MY GYAT MY ENGINE IS MISSING"); } + public void restHonda() { if(gm.player.playerLife != gm.player.playerMaxLife) { gm.ui.messageText.setText("*You rest on the hood of your car*\n(Your life has been recovered)"); diff --git a/src/main/java/event/Event03.java b/src/main/java/event/Event03.java index d0d0de4..0afeb77 100644 --- a/src/main/java/event/Event03.java +++ b/src/main/java/event/Event03.java @@ -13,9 +13,11 @@ public Event03(GameManager gm) { public void lookHondaur() { gm.ui.messageText.setText("Its a Hondaur"); } + public void talkHondaur() { gm.ui.messageText.setText("The Hondaur growls at you and revs his engine "); } + public void attackHondaur() { gm.ui.messageText.setText("*You start beating the shit out of the poor Hondaur*"); diff --git a/src/main/java/event/Event04.java b/src/main/java/event/Event04.java index 05e8356..4fe3b41 100644 --- a/src/main/java/event/Event04.java +++ b/src/main/java/event/Event04.java @@ -14,8 +14,8 @@ public void lookDenzel() { gm.ui.messageText.setText("This is Denzel. (He listens to Valorant music)"); } public void talkDenzel() { - if(gm.player.hasPistol == 0) { - gm.player.hasPistol = 1; + if(!gm.player.hasPistol) { + gm.player.hasPistol = true; gm.ui.messageText.setText("My oh my I've been waiting for you heh. Here's a glock.\nI saw a monster running with an engine towards the casino!"); gm.player.updatePlayerStatus(); diff --git a/src/main/java/event/Event05.java b/src/main/java/event/Event05.java index 1d44ad5..9a1bf6a 100644 --- a/src/main/java/event/Event05.java +++ b/src/main/java/event/Event05.java @@ -11,7 +11,7 @@ public Event05(GameManager gm) { this.gm = gm; } public void lookHondaTrunk() { - if(gm.player.hasPistol == 1){ + if(gm.player.hasPistol){ gm.ui.messageText.setText("IS THAT BRIAN FROM MARAUDER CODED!"); } else{ @@ -20,7 +20,7 @@ public void lookHondaTrunk() { } public void talkHondaTrunk() { if(gm.theodoor.currentLife==0 && gm.wheeler.currentLife==0) { - if(gm.player.hasPistol == 1){ + if(gm.player.hasPistol){ gm.ui.messageText.setText("Eughh Please... save... Julien and please end my misery"); } else{ @@ -35,14 +35,14 @@ public void talkHondaTrunk() { public void killHondaTrunk() { if(gm.theodoor.currentLife == 0 && gm.wheeler.currentLife == 0) { - if(gm.player.hasPistol == 1){ + if(gm.player.hasPistol){ gm.playSE(gm.pistolShot); gm.ui.messageText.setText("(You ended Brian's misery)"); } else{ gm.ui.messageText.setText("(You already ended his misery!)"); } - gm.player.hasPistol = 0; + gm.player.hasPistol = false; gm.player.updatePlayerStatus(); } else{ diff --git a/src/main/java/event/Event06.java b/src/main/java/event/Event06.java index ddb4d8a..bb4650c 100644 --- a/src/main/java/event/Event06.java +++ b/src/main/java/event/Event06.java @@ -8,7 +8,6 @@ public class Event06 { private ImageView denzel; public Event06(GameManager gm) { - this.gm = gm; } public void reset(){ @@ -26,8 +25,8 @@ public void talkDenzel(){ } public void playDenzel(){ - if(gm.player.hasAk47 == 0) { - gm.player.hasAk47 = 1; + if(!gm.player.hasAk47) { + gm.player.hasAk47 = true; gm.ui.messageText.setText("*You cheer Denzel up by playing Valorant music*\nYou realy know how to cheer me up!\n *Denzel gives you an ak47*"); gm.player.updatePlayerStatus(); @@ -43,6 +42,7 @@ public void playDenzel(){ public void lookBrandon() { gm.ui.messageText.setText("This is Brandon. He seems to be doing a fit check"); } + public void talkBrandon() { gm.ui.messageText.setText("Yo I wouldn't go in there if I were you! A monster is on the loose!"); } diff --git a/src/main/java/event/Event07.java b/src/main/java/event/Event07.java index 96a2825..8f0a06a 100644 --- a/src/main/java/event/Event07.java +++ b/src/main/java/event/Event07.java @@ -13,12 +13,13 @@ public Event07(GameManager gm) { } public void lookJulian() { gm.ui.messageText.setText("Julian is in serious condition"); - if(julianLife ==0) { + if(julianLife == 0) { gm.ui.messageText.setText("You see Julien's lifeless body"); } } public void talkJulian() { - if(julianLife == 2 || julianLife == 1) { + //Change it to "If Julian has lives" + if(julianLife > 0) { gm.ui.messageText.setText("*Julian cries when he sees you* I don't want to die..."); } else { @@ -27,50 +28,57 @@ public void talkJulian() { } } public void holdJulian() { - if(julianLife == 2) { - gm.ui.messageText.setText("*You hold Julian's hand and tell him it'll be okay*\nJulian says his last words: Can you spin it one last time for me?"); - julianLife=1; - } - if(julianLife == 1) { - gm.ui.messageText.setText("*You hold Julian's hand and tell him it'll be okay*\nJulian says his last words: Can you spin it one last time for me?"); - } - else{ - gm.ui.messageText.setText("Julian is already dead"); - gm.playSE(gm.cannotSound); + //create a switch statement for this method using the number of Julian lives + switch(julianLife) { + case 2: + gm.ui.messageText.setText("*You hold Julian's hand and tell him it'll be okay*\nJulian says his last words: Can you spin it one last time for me?"); + julianLife--; + break; + case 1: + gm.ui.messageText.setText("*You hold Julian's hand and tell him it'll be okay*\nJulian says his last words: Can you spin it one last time for me?"); + break; + default: + gm.ui.messageText.setText("Julian is already dead"); + gm.playSE(gm.cannotSound); + break; } } public void lookSlotMachine() { gm.ui.messageText.setText("You see the slot machine that the Marauder Coded gang made"); } + public void talkSlotMachine() { gm.ui.messageText.setText("(The slot machine displays your aura: 10,000,000)"); } + public void spinSlotMachine() { - if(julianLife == 1) { - gm.ui.messageText.setText("*You spin*\n YOU WIN 6 MILLION DOLLARS!!!\n *Julien sighs and passes away*"); - julianLife =0; - gm.playSE(gm.slotWin); - } - else{ - if(julianLife == 2) { + //use a switch statement with Julian's lives + switch(julianLife) { + case 2: gm.ui.messageText.setText("You must hold Julian first!"); gm.playSE(gm.cannotSound); - } - if(julianLife < 1) { + break; + case 1: + gm.ui.messageText.setText("*You spin*\n YOU WIN 6 MILLION DOLLARS!!!\n *Julien sighs and passes away*"); + julianLife--; + gm.playSE(gm.slotWin); + break; + default: gm.ui.messageText.setText("*You have no more spins left*"); gm.playSE(gm.cannotSound); - } + break; } - } + public void lookAdrian() { gm.ui.messageText.setText("You see Adrian, the leader of the Honda Boyz"); } + public void talkAdrian() { gm.ui.messageText.setText("It was supposed to be an era of peace between the Honda Boyz and Marauder Coded\n *Adrian cries*\n I tried to save him I really did"); } + public void thankAdrian() { gm.ui.messageText.setText("*You thank Adrian for his great efforts*\n (Adrian will give you 10% of his profits if you avenge Julian)"); - } } diff --git a/src/main/java/main/ActionHandler.java b/src/main/java/main/ActionHandler.java index 2716af9..21ebe6e 100644 --- a/src/main/java/main/ActionHandler.java +++ b/src/main/java/main/ActionHandler.java @@ -20,6 +20,12 @@ public void handle(ActionEvent e) { handleAction(yourChoice); } + //TODO create an enum to map an interaction with a Honda Boy to a respective action + + + + //TODO break handleAction() into multiple smaller functions that deal with each scene to make code more readable + // handles the action commands public void handleAction(String yourChoice) { switch (yourChoice) { @@ -182,7 +188,7 @@ public void handleAction(String yourChoice) { gm.sChanger.showScene1(); break; case "goScene2": - if(gm.player.hasFlashlight == 1){ + if(gm.player.hasFlashlight){ gm.sChanger.showScene2(); } else { @@ -203,7 +209,7 @@ public void handleAction(String yourChoice) { } break; case "goScene5": - if(gm.player.hasPistol == 1){ + if(gm.player.hasPistol){ gm.sChanger.showScene5(); } else { diff --git a/src/main/java/main/GameManager.java b/src/main/java/main/GameManager.java index cd88b9e..6c691e3 100644 --- a/src/main/java/main/GameManager.java +++ b/src/main/java/main/GameManager.java @@ -41,8 +41,11 @@ public class GameManager extends Application { Music music = new Music(); SoundEffect se = new SoundEffect(); + //TODO create an String array with the name of the .wav files + + //TODO create an enhanced for loop that applies getClass().getClassLoader.getResource() on each .wav file, parse the name of the .wav file, and assign it to a variable of that name //SOUND - public URL mainTheme = getClass().getClassLoader().getResource("mainTheme.wav"); + public URL mainTheme = getClass().getClassLoader().getResource("mainTheme.wav"); public URL monsterTheme = getClass().getClassLoader().getResource("monsterTheme.wav"); public URL casinoMusic = getClass().getClassLoader().getResource("casinoMusic.wav"); public URL slotWin = getClass().getClassLoader().getResource("slotWin.wav"); diff --git a/src/main/java/main/Player.java b/src/main/java/main/Player.java index cd20c21..6a5034c 100644 --- a/src/main/java/main/Player.java +++ b/src/main/java/main/Player.java @@ -10,9 +10,10 @@ public class Player { public int playerMaxLife; public int playerLife; - public int hasFlashlight; - public int hasPistol; - public int hasAk47; + //TODO: since the game only uses one of each of these items, use a boolean to check if player has these items + public boolean hasFlashlight; + public boolean hasPistol; + public boolean hasAk47; public Player(GameManager gm) { @@ -24,9 +25,9 @@ public void setPlayerDefaultStatus() { playerMaxLife = 5; playerLife = 2; - hasFlashlight = 0; - hasPistol = 0; - hasAk47 = 0; + hasFlashlight = false; + hasPistol = false; + hasAk47 = false; updatePlayerStatus(); } @@ -48,9 +49,9 @@ public void updatePlayerStatus() { } // CHECK PLAYER ITEMS - gm.ui.flashlightLabel.setVisible(hasFlashlight == 1); - gm.ui.pistolLabel.setVisible(hasPistol == 1); - gm.ui.ak47Label.setVisible(hasAk47 == 1); + gm.ui.flashlightLabel.setVisible(hasFlashlight); + gm.ui.pistolLabel.setVisible(hasPistol); + gm.ui.ak47Label.setVisible(hasAk47); } } diff --git a/src/main/java/main/SceneChanger.java b/src/main/java/main/SceneChanger.java index b1d5043..56d9aaf 100644 --- a/src/main/java/main/SceneChanger.java +++ b/src/main/java/main/SceneChanger.java @@ -4,22 +4,37 @@ * This class handles the transition of scenes */ public class SceneChanger { + //create a variable holding the number of events + public int numOfScenes = 9; GameManager gm; public SceneChanger(GameManager gm) { - this.gm = gm; } + /** + * This function uses a for loop to render the desired scene + * Sets all other scenes to false using a for loop + * @param sceneNum the desired scene to be rendered + */ + public void showSpecificScene(int sceneNum) { + //render desired scene + gm.ui.bgPane[sceneNum].setVisible(true); + + for (int i = 1; i < numOfScenes + 1; i++) { + if(i == sceneNum) { + continue; + } else { + gm.ui.bgPane[i].setVisible(false); + } + } + + } + public void showScene1(){ + showSpecificScene(1); - gm.ui.bgPane[1].setVisible(true); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); gm.ui.messageText.setText("You are inside your room and you hear a sus sound outside"); gm.stopMusic(gm.currentMusic); @@ -28,21 +43,13 @@ public void showScene1(){ } public void showScene2(){ - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(true); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); + showSpecificScene(2); + gm.ui.messageText.setText("You are outside your house"); } public void showScene3(){ - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(true); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); + showSpecificScene(3); + gm.ui.messageText.setText("The Engine Monster Stealer gets away and you find yourself lost in the woods"); gm.stopMusic(gm.currentMusic); @@ -50,12 +57,8 @@ public void showScene3(){ gm.playMusic(gm.currentMusic); } public void showScene4() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(true); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); + showSpecificScene(4); + gm.ui.messageText.setText("You find a tall, dark, and handsome man"); gm.stopMusic(gm.currentMusic); @@ -63,12 +66,8 @@ public void showScene4() { gm.playMusic(gm.currentMusic); } public void showScene5() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(true); - gm.ui.bgPane[6].setVisible(false); + showSpecificScene(5); + gm.ui.messageText.setText("The Casino is up ahead but 2 monsters block your way!"); gm.stopMusic(gm.currentMusic); @@ -76,12 +75,8 @@ public void showScene5() { gm.playMusic(gm.currentMusic); } public void showScene6() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(true); + showSpecificScene(6); + gm.ui.messageText.setText("You followed the sound of havoc and made your way to the Casino"); gm.stopMusic(gm.currentMusic); @@ -89,13 +84,8 @@ public void showScene6() { gm.playMusic(gm.currentMusic); } public void showScene7() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); - gm.ui.bgPane[7].setVisible(true); + showSpecificScene(7); + gm.ui.messageText.setText("You enter the Casino but its too late"); gm.stopMusic(gm.currentMusic); @@ -103,14 +93,8 @@ public void showScene7() { gm.playMusic(gm.currentMusic); } public void showScene8() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); - gm.ui.bgPane[7].setVisible(false); - gm.ui.bgPane[8].setVisible(true); + showSpecificScene(8); + gm.ui.messageText.setText("You catch up to the monster"); gm.stopMusic(gm.currentMusic); @@ -118,15 +102,7 @@ public void showScene8() { gm.playMusic(gm.currentMusic); } public void viewLeaderboard() { - gm.ui.bgPane[1].setVisible(false); - gm.ui.bgPane[2].setVisible(false); - gm.ui.bgPane[3].setVisible(false); - gm.ui.bgPane[4].setVisible(false); - gm.ui.bgPane[5].setVisible(false); - gm.ui.bgPane[6].setVisible(false); - gm.ui.bgPane[7].setVisible(false); - gm.ui.bgPane[8].setVisible(false); - gm.ui.bgPane[9].setVisible(true); + showSpecificScene(9); gm.showLeaderboard(); gm.stopMusic(gm.currentMusic); diff --git a/src/main/java/main/SoundEffect.java b/src/main/java/main/SoundEffect.java index 6410d8e..8732a79 100644 --- a/src/main/java/main/SoundEffect.java +++ b/src/main/java/main/SoundEffect.java @@ -12,8 +12,7 @@ public class SoundEffect { Clip clip; - public void setFile(URL name){ - + public void setFile(URL name) { try{ AudioInputStream sound = AudioSystem.getAudioInputStream(name); clip = AudioSystem.getClip(); diff --git a/src/main/java/main/TimeManager.java b/src/main/java/main/TimeManager.java index 25d9b19..f2337a7 100644 --- a/src/main/java/main/TimeManager.java +++ b/src/main/java/main/TimeManager.java @@ -10,6 +10,8 @@ import java.util.List; public class TimeManager { + //TODO use log4j2 for exception handling. For larger applications, it is usually better to use a logger than System.err.println() + private static final String BINARY_FILE_NAME = "fastest_times.dat"; private static final String LEADERBOARD_FILE_NAME = "leaderboard.csv"; public ArrayList fastestTimes = new ArrayList<>(); @@ -92,7 +94,9 @@ void loadLeaderboard() { System.err.println("Error loading leaderboard: " + e.getMessage()); } } - public class TimeUtils { + + //made TimeUtils static + public static class TimeUtils { public static String formatTime(long millis) { long seconds = millis / 1000; long minutes = seconds / 60; @@ -107,4 +111,10 @@ public static long parseFormattedTime(String formattedTime) { return (minutes * 60 + seconds) * 1000; // Convert to milliseconds } } + + //TODO create a method to reset the leaderboard + + //TODO use a multithread to show the user's time move down the ranks of a leaderboard + + //TODO implement a way to add the date to when a leaderboard entry is made } diff --git a/src/main/java/main/UI.java b/src/main/java/main/UI.java index be2b253..6df67ee 100644 --- a/src/main/java/main/UI.java +++ b/src/main/java/main/UI.java @@ -80,10 +80,14 @@ public void createTitleScreen(Stage primaryStage) { timeline.play(); - //START BUTTON + /* + TODO instead of hardcoding dimensions of buttons, + use Bindings to dynamically adjust dimensions + Ex: startButton.layoutXProperty().bind(window.widthProperty().subtract(startButton.widthProperty()).divide(2)); + */ Button startButton = new Button("Start"); startButton.setStyle("-fx-font-family: 'Arial'; -fx-font-size: 24px; -fx-background-color: white;"); - startButton.setLayoutX((800 - 150) / 2); // Center horizontally (approximate for button width) + startButton.setLayoutX((double) (800 - 150) / 2); // Center horizontally (approximate for button width) startButton.setLayoutY(400); // Center vertically (approximate for button height) // Start button functionality @@ -167,6 +171,8 @@ public void createBackground(int bgNum, String bgFileName) { ((Pane) window.getScene().getRoot()).getChildren().add(bgPane[bgNum]); } + //TODO createObject() and createObjectAndReturn() are very identical, perhaps condense them into one helper method? + public void createObject(int bgNum, int objx, int objy, int objWidth, int objHeight, String objFileName, String choice1Name, String choice2Name, String choice3Name, String choice1Command, String choice2Command, String choice3Command) { // Context Menu for Object @@ -337,6 +343,8 @@ public void displayLeaderboard(List leaderboard) { alert.showAndWait(); } + //TODO create a button/option for the user to view a live leaderboard that checks if the user's running time is greater than entries on the leaderboard and updates accordingly + public void generateScene() { // SCENE 1 createBackground(1, "bedroom.png"); diff --git a/src/main/java/monsters/EngineStealerMonster.java b/src/main/java/monsters/EngineStealerMonster.java index 7ae0240..cd26ad9 100644 --- a/src/main/java/monsters/EngineStealerMonster.java +++ b/src/main/java/monsters/EngineStealerMonster.java @@ -26,7 +26,7 @@ public void talkSponge2(){ gm.playSE(gm.monsterRoar); } public void attackSponge(){ - if(gm.player.hasAk47 == 1 && gm.player.hasPistol ==0){ + if(gm.player.hasAk47 && !gm.player.hasPistol){ currentLife -= 5; gm.player.playerLife -= 2; gm.player.updatePlayerStatus(); @@ -34,7 +34,7 @@ public void attackSponge(){ gm.playSE(gm.ak47shots); gm.playSE(gm.monsterRoar); } - if(gm.player.hasPistol == 1 && gm.player.hasAk47 == 0){ + if(gm.player.hasPistol && !gm.player.hasAk47){ currentLife -= 2; gm.player.playerLife -= 2; gm.player.updatePlayerStatus(); @@ -42,7 +42,7 @@ public void attackSponge(){ gm.playSE(gm.pistolShot); gm.playSE(gm.monsterRoar); } - if(gm.player.hasAk47 == 1 && gm.player.hasPistol == 1){ + if(gm.player.hasAk47 && gm.player.hasPistol){ currentLife -= 5; gm.player.playerLife -= 2; gm.player.updatePlayerStatus(); diff --git a/src/main/java/monsters/Hondaur.java b/src/main/java/monsters/Hondaur.java index 84afd64..0f3c37f 100644 --- a/src/main/java/monsters/Hondaur.java +++ b/src/main/java/monsters/Hondaur.java @@ -20,7 +20,7 @@ public void addToScene() { @Override public void lookHondaur() { - if(currentLife >0) { + if(currentLife > 0) { gm.ui.messageText.setText("You see a fearsome weakened " + monster+ " ready to rev its engine."); gm.playSE(gm.monsterRoar); } @@ -29,9 +29,10 @@ public void lookHondaur() { gm.playSE(gm.cannotSound); } } + @Override public void talkHondaur() { - if(currentLife >0) { + if(currentLife > 0) { gm.ui.messageText.setText("The "+monster+" growls at you, its engine roaring."); gm.playSE(gm.monsterRoar); } @@ -40,14 +41,15 @@ public void talkHondaur() { gm.playSE(gm.cannotSound); } } + @Override public void attackHondaur() { - currentLife--; - gm.player.playerLife -=1; + gm.player.playerLife--; gm.player.updatePlayerStatus(); gm.ui.messageText.setText("You attack the "+monster+" with your fists! (Its health decreases)"); - if(gm.player.playerLife <=0){ + + if(gm.player.playerLife < 1){ gm.sChanger.showGameOverScreen(3); gm.ui.messageText.setText("You baka! You tested your luck!"); } @@ -57,7 +59,7 @@ public void attackHondaur() { } - if(currentLife == 0){ + if(currentLife < 1) { if (blood == null) { blood = gm.ui.createObjectAndReturn(3, 340, 100, 200, 233, "blood.png", "", "", "", "", "", ""); } @@ -71,7 +73,7 @@ public void attackHondaur() { anthony.setVisible(true); gm.ui.messageText.setText("The " + monster+ " has been defeated!"); - }else if (currentLife > 0) { + }else { // Hide anthony and blood while the monster is still alive if (anthony != null) anthony.setVisible(false); if (blood != null) blood.setVisible(false); @@ -104,6 +106,8 @@ public void touchAnthony() { gm.ui.messageText.setText("*You grasp his cheek. He sheds a tear* My boy Denzel should be up ahead!"); } + + //No need to write all these empty overrides. Just make these methods concrete in their respective monster clases. Why is code for Wheeler Monster in Hondaur class? @Override public void lookTheodoor() {} @Override diff --git a/src/main/java/monsters/Theodoor.java b/src/main/java/monsters/Theodoor.java index ee83726..e774f41 100644 --- a/src/main/java/monsters/Theodoor.java +++ b/src/main/java/monsters/Theodoor.java @@ -19,7 +19,7 @@ public void addToScene() { @Override public void lookTheodoor() { - if(currentLife >0) { + if(currentLife > 0) { gm.ui.messageText.setText("You see " + monster+ " the door ready to feast on your adorable body."); gm.playSE(gm.monsterRoar); } @@ -31,7 +31,7 @@ public void lookTheodoor() { @Override public void talkTheodoor() { - if(currentLife >0) { + if(currentLife > 0) { gm.ui.messageText.setText(monster+" the door roars at you, its hinges creaking."); gm.playSE(gm.monsterRoar); } @@ -47,7 +47,7 @@ public void attackTheodoor() { gm.player.playerLife -=1; gm.player.updatePlayerStatus(); gm.ui.messageText.setText("You shoot "+monster+" the door with your glock! (Its health decreases by 2)"); - if(gm.player.playerLife <=0){ + if(gm.player.playerLife < 1){ gm.sChanger.showGameOverScreen(5); gm.ui.messageText.setText("You baka! You tested your luck!"); }