Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tutorial.main;
- import java.awt.FontFormatException;
- import java.io.File;
- import java.io.IOException;
- import java.util.Random;
- import javax.sound.sampled.AudioInputStream;
- import javax.sound.sampled.AudioSystem;
- import javax.sound.sampled.Clip;
- import javax.sound.sampled.LineUnavailableException;
- import javax.sound.sampled.UnsupportedAudioFileException;
- //One instance of this class will be made. That class will have as variables...every piece of menu data, for easy,
- //object oriented retrieval. Yes.
- public class MenuLibrary {
- public Menu resultMenu;
- AudioInputStream stream;
- Clip clip;
- BackGroundSound cityNoise;
- File filePathSound = new File("").getAbsoluteFile();
- public MoneyEffect moneyEffectML;
- private Random r;
- private String invTitle = "Inventory";
- private String invPrompt = "";
- private String[][] invOptions = {};
- private ChoiceProcessorInterface invProcessor;
- //private ID inventoryMenuType = ID.InventoryMenu;
- public MenuDataArchive invArchive;
- private String mainMenuPrompt = ""; //this is replaced by the logo image
- private String[][] mainMenuOptions = {
- {"Begin", "mainMenuBegin"},
- {"Instructions", "mainMenuInstructions"},
- {"Quit", "mainMenuQuit"} };
- private ChoiceProcessorInterface mainMenuProcessor;
- public MenuDataArchive mainMenuArchive;
- private String creditDeniedPrompt = "You swipe your credit card and the register flashes \"DENIED\". " +
- " Looks like you won't be buying anything today.";
- private String[][] creditDeniedOptions = { {"Okay", "leave"} };
- private ChoiceProcessorInterface creditDeniedProcessor;
- public MenuDataArchive creditDeniedArchive;
- private String burgerTitle = "McSpanky's Burgers";
- private String burgerPrompt = "It smells like fast food and grease in here. But it's cheap, and they're hiring.";
- private String[][] burgerOptions = { {"Buy a Meal ($4.99)", "buyBurgerFood"},
- {"Apply for a Job", "applyBurgerJob"},
- {"Leave", "leaveBurger"} };
- private ChoiceProcessorInterface burgerProcessor;
- public MenuDataArchive burgerArchive;
- private String burger0Prompt = "The fast food isn't very filling.";
- private String[][] burger0Options = { {"Okay", "burger0Leave"} };
- private ChoiceProcessorInterface burger0Processor;
- public MenuDataArchive burger0Archive;
- private String burger1Prompt = "After an interview with the manager, you're handed your schedule for the first week."
- + " Not exactly convenient, but you suppose you can make time. (9-5 on weekdays)";
- private String[][] burger1Options = { {"Happy to McServe you, sir.", "startBurgerJob"} };
- private ChoiceProcessorInterface burger1Processor;
- public MenuDataArchive burger1Archive;
- private String burger2Title = "Welcome McWorker!";
- private String burger2Prompt = "Make sure you sign in at your assigned shift time, 9-5 on weekdays";
- private String[][] burger2Options = { {"Sign in to shift", "signIn"}, {"Buy a Meal ($3.50 with employee discount)", "buyBurgerFood"},
- {"Quit Job", "quit"}, {"Exit Menu", "burger2Leave"}};
- private ChoiceProcessorInterface burger2Processor;
- public MenuDataArchive burger2Archive;
- private String burgerSignOut = "Good job finishing your shift! Your wallet is happy but your health certainly isn't";
- private String[][] burgerSOOptions = { {"Exit", "exitBurger"} };
- private ChoiceProcessorInterface burgerSOProcessor;
- public MenuDataArchive burgerSOArchive;
- private String burgerOffTitle = "Off-shift menu";
- private String burgerOffPrompt = "You're off your shift! Use your employee discount to buy a burger";
- private String[][] burgerOffOptions = { {"Buy a Meal ($3.50)", "buyBurgerFood"}, {"Quit Job", "quitBurgerJob"}, {"Okay", "burgerOffLeave"}};
- private ChoiceProcessorInterface burgerOffProcessor;
- public MenuDataArchive burgerOffArchive;
- private String burgerFiredTitle = "McSpanky's Burgers";
- private String burgerFPrompt = "It smells like fast food and grease in here. But it's cheap. You cannot work for a place that you've been fired from";
- private String[][] burgerFOptions = { {"Buy a Meal ($4.99)", "buyBurgerFood"},
- {"Leave", "leaveBurger"} };
- private ChoiceProcessorInterface burgerFProcessor;
- public MenuDataArchive burgerFArchive;
- private String apartmentPrompt = "It's your apartment.";
- private String[][] apartmentOptions = { {"Sleep", "sleepApartment"}, {"Leave", "leave"} };
- private ChoiceProcessorInterface apartmentProcessor;
- public MenuDataArchive apartmentTopArchive;
- public static SleepEffect sleepEffect;
- private String apartmentTitle = "Your Apartment";
- private String apartment0Prompt = "You wake up, feeling not quite as rested as you'd like.";
- private String[][] apartment0Options = { {"Leave apartment", "leave"} };
- private ChoiceProcessorInterface apartment0Processor;
- public MenuDataArchive apartment0Archive;
- //apartment logic variables
- private int nextMorning;
- private int timeSlept;
- public MenuDataArchive apartmentArchive;
- private String collegeTitle = "S.U. Community College";
- private String collegePrompt = "The local University's admissions office. They have pamphlets that detail the costs of "
- + "attendance. It will not be cheap.";
- private String[][] collegeOptions = { {"Pay Tuition($10,000)", "payTuition"}, {"Leave", "leave"} };
- private ChoiceProcessorInterface collegeProcessor;
- public MenuDataArchive collegeArchive;
- private String college0Prompt = "As you sign the paperwork, you feel hope for the first time in a long time. You believe"
- + " things are going to get better.";
- private String[][] college0Options = { {"Thanks for Playing!", "leave"} };
- private ChoiceProcessorInterface college0Processor;
- public MenuDataArchive college0Archive;
- private String walmartTitle = "Wolmart";
- private String walmartPrompt = "The hum of fluorescent light bulbs and off white paint tone are the first things you"
- + " notice as you walk in, but they fade into the background as you browse the aisles.";
- private String[][] walmartOptions = {
- {"Buy 1 day of groceries ($10)", "buy1Grocery"},
- {"Buy 7 days of groceries ($40)", "buy7Grocery"},
- {"Buy a Bike", "buyBike"},
- {"Leave", "leave"}
- };
- private ChoiceProcessorInterface walmartProcessor;
- public MenuDataArchive walmartArchive;
- private String hospitalTitle = "M.D. Anderson Clinic";
- private String hospitalPrompt = "It's the hospital reception room.";
- private String[][] hospitalOptions = { {"Check Up ($500/2 Hours)", "checkUp"}, {"Leave", "leave"} };
- private ChoiceProcessorInterface hospitalProcessor;
- public MenuDataArchive hospitalArchive;
- private String hospital0Prompt = "You feel much better after your checkup.";
- private String[][] hospital0Options = { {"Leave", "leave"} };
- private ChoiceProcessorInterface hospital0Processor;
- public MenuDataArchive hospital0Archive;
- private String eventFindMoneyPrompt = "You find a few coins on the ground.";
- private String[][] eventFindMoneyOptions = { {"How Lucky!", "leave"} };
- private ChoiceProcessorInterface eventFindMoneyProcessor;
- public MenuDataArchive eventFindMoneyArchive;
- private String eventCollapsePrompt = "You feel really tired. Really tired. You're going to lay down for a second. Just a quick second.";
- private String[][] eventCollapseOptions = { {"A quick rest...", "collapse"} };
- private ChoiceProcessorInterface eventCollapseProcessor;
- public MenuDataArchive eventCollapseArchive;
- private String eventCollapse0Prompt = "Your whole body is stiff. You fell asleep outside. And didn't you have more money on you yesterday?";
- private String[][] eventCollapse0Options = { {"Try to get more sleep next time.", "leave"} };
- private ChoiceProcessorInterface eventCollapse0Processor;
- public MenuDataArchive eventCollapse0Archive;
- private String eventCollapse0NoMoneyPrompt = "Your whole body is stiff. You fell asleep outside.";
- private String[][] eventCollapse0NoMoneyOptions = { {"Try to get more sleep next time.", "leave"} };
- private ChoiceProcessorInterface eventCollapse0NoMoneyProcessor;
- public MenuDataArchive eventCollapse0NoMoneyArchive;
- private String eventStrikesPrompt = "Oops! You're late to work (2 hrs past shift start). You recieved a strike!"
- + "You get 3 strikes at a job before you will be fired! Be careful!";
- private String[][] eventStrikesOptions = { {"Understood", "exitStrikes"} };
- private ChoiceProcessorInterface eventStrikesProcessor;
- public MenuDataArchive eventStrikesArchive;
- private String kickedOutPrompt = "As soon as you walk in, you're practically chased out by an employee. They make a rude comment about the state"
- + " of your clothes before shutting the door in your face.";
- private String[][] kickedOutOptions = { {"Leave", "leave"} };
- private ChoiceProcessorInterface kickedOutProcessor;
- public MenuDataArchive kickedOutArchive;
- MenuLibrary() {
- r = new Random();
- this.invArchive = new MenuDataArchive(invPrompt, invOptions, invProcessor, ID.InventoryMenu, invTitle);
- this.mainMenuProcessor = (String choiceIDPr) -> {
- System.out.println("choice ID = " + choiceIDPr);
- switch (choiceIDPr) {
- case "mainMenuBegin":
- try {
- Game.thisGame.gameMapSetup();
- } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Game.mainMenuOpen = false;
- Game.gameState = Game.STATES.Playing;
- Game.handler.removeObject(Game.mainMenu);
- Game.thisGame.removeKeyListener(Game.mainMenu);
- HUD.hungerFullnessDelayedX = 200;
- try {
- stream = AudioSystem.getAudioInputStream(PlayerInput.class.getResource("cityAmbience.wav"));
- clip = AudioSystem.getClip();
- cityNoise = new BackGroundSound((long) 0.0, clip, "?", stream, filePathSound);
- cityNoise.play();
- } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- break;
- case "mainMenuInstructions":
- System.out.println("GAME INSTRUCTIONS DEBUG");
- break;
- case "mainMenuQuit":
- System.out.println("GAME QUIT DEBUG");
- System.exit(1);
- break;
- }
- };
- mainMenuArchive = new MenuDataArchive(mainMenuPrompt, mainMenuOptions, mainMenuProcessor, ID.MainMenu, null);
- this.creditDeniedProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "leave":
- closeResultMenu();
- break;
- }
- };
- creditDeniedArchive = new MenuDataArchive(creditDeniedPrompt, creditDeniedOptions, creditDeniedProcessor, ID.ResultMenu, null);
- //=====================================================================================================================
- this.burgerProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "buyBurgerFood" :
- if (Finance.tryBuy(4.99)) {
- try {
- resultMenu = new Menu(burger0Archive);
- } catch (FontFormatException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- makeResultMenu();
- closeOldMenu();
- HUD.hunger += 10;
- } else {
- //play sound
- System.out.println("No money.");
- }
- break;
- case "applyBurgerJob" :
- try {
- resultMenu = new Menu(burger1Archive);
- } catch (FontFormatException | IOException e) {
- e.printStackTrace();
- }
- makeResultMenu();
- closeOldMenu();
- break;
- case "leaveBurger" :
- closeOldMenu();
- closeResultMenu();
- break;
- }
- };
- this.burger0Processor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "burger0Leave" :
- closeResultMenu();
- break;
- }
- };
- this.burger1Processor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "startBurgerJob" :
- System.out.println("starting burger job");
- closeResultMenu();
- Game.jobFunction.jobList.get(0).setHasJob(true);
- break;
- }
- };
- this.burger2Processor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "signIn" :
- System.out.println("signing into job");
- if (Game.jobFunction.jobList.get(0).onJob()) {
- int fivePM = (int) ((17 * 60 * HUD.gameSlowFactor) + ((HUD.day - 1) * 1440 * HUD.gameSlowFactor));
- double timeWorked = fivePM - HUD.rawTimeElapsed;
- double pay = (timeWorked * 8.5) / (60 * HUD.gameSlowFactor);
- HUD.rawTimeElapsed = fivePM; //timelapses to 5pm
- System.out.println("Signed out of job");
- try {
- resultMenu = new Menu(burgerSOArchive);
- } catch (FontFormatException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Game.moneyChangeCause = "Worked at Job";
- HUD.money += pay;//pay should be dependent on how many hours worked
- HUD.hunger -= (HUD.METABOLISM / HUD.gameSlowFactor) * timeWorked;
- HUD.energy -= (HUD.ENERGY_LOSS / HUD.gameSlowFactor) * timeWorked;
- makeResultMenu(); //shows a menu after timelapse
- closeOldMenu();
- }
- break;
- case "buyBurgerFood" :
- if (Finance.tryBuy(3.50)) {
- try {
- resultMenu = new Menu(burger0Archive);
- } catch (FontFormatException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- makeResultMenu();
- closeOldMenu();
- HUD.hunger += 10;
- } else {
- //play sound
- System.out.println("No money.");
- }
- break;
- case "quit" :
- System.out.println("quit job");
- closeOldMenu();
- closeResultMenu();
- //for now, future: lead back to old menu & give quit message
- break;
- case "burger2Leave" :
- closeOldMenu();
- closeResultMenu();
- break;
- }
- };
- this.burgerSOProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "exitBurger" :
- closeResultMenu();
- break;
- }
- };
- this.burgerOffProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "buyBurgerFood" :
- if (Finance.tryBuy(3.50)) {
- try {
- resultMenu = new Menu(burger0Archive);
- } catch (FontFormatException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- makeResultMenu();
- closeOldMenu();
- HUD.hunger += 10;
- } else {
- //play sound
- System.out.println("No money.");
- }
- break;
- case "burgerOffLeave" :
- closeOldMenu();
- closeResultMenu();
- break;
- case "quitBurgerJob" :
- closeOldMenu();
- closeResultMenu();
- break; //temporarily until quitting system is ok.
- }
- };
- this.burgerFProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "buyBurgerFood" :
- if (Finance.tryBuy(4.99)) {
- try {
- resultMenu = new Menu(burger0Archive);
- } catch (FontFormatException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- makeResultMenu();
- closeOldMenu();
- HUD.hunger += 10;
- } else {
- //play sound
- System.out.println("No money.");
- }
- break;
- case "leaveBurger" :
- closeOldMenu();
- closeResultMenu();
- break;
- }
- };
- burger0Archive = new MenuDataArchive(burger0Prompt, burger0Options, burger0Processor, ID.ResultMenu, null);
- burger1Archive = new MenuDataArchive(burger1Prompt, burger1Options, burger1Processor, ID.ResultMenu, null);
- burgerSOArchive = new MenuDataArchive(burgerSignOut, burgerSOOptions, burgerSOProcessor, ID.ResultMenu, null);
- burger2Archive = new MenuDataArchive(burger2Prompt, burger2Options, burger2Processor, ID.ChoiceMenu, burger2Title);
- burgerOffArchive = new MenuDataArchive(burgerOffPrompt, burgerOffOptions, burgerOffProcessor, ID.ChoiceMenu, burgerOffTitle);
- burgerArchive = new MenuDataArchive(burgerPrompt, burgerOptions, burgerProcessor, ID.ChoiceMenu, burgerTitle);
- burgerFArchive = new MenuDataArchive(burgerFPrompt, burgerFOptions, burgerFProcessor, ID.ChoiceMenu, burgerFiredTitle);
- this.apartmentProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "sleepApartment" :
- try {
- cityNoise.stop();
- } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) {
- e.printStackTrace();
- }
- try {
- resultMenu = new Menu(apartment0Archive);
- } catch (FontFormatException | IOException e) {
- e.printStackTrace();
- }
- sleepEffect = new SleepEffect(0, 0, ID.SleepEffect);
- Game.handler.addObject(sleepEffect);
- Game.gameState = Game.STATES.Sleeping;
- if (HUD.hoursSinceMidnight > 6) {
- nextMorning = (int) ((8 * 60 * HUD.gameSlowFactor) + (HUD.day * 1440 * HUD.gameSlowFactor) - 1);
- } else {
- nextMorning = (int) ((8 * 60 * HUD.gameSlowFactor) + ((HUD.day - 1) * 1440 * HUD.gameSlowFactor) - 1);
- }
- //player wakes up at 7:59 AM so they have time to make their 8 AM rent payment
- timeSlept = (int) (nextMorning - HUD.rawTimeElapsed);
- HUD.energy += SleepEffect.getEnergyRestored();
- HUD.rawTimeElapsed = nextMorning; //set gameTime to the next morning
- makeResultMenu();
- closeOldMenu();
- break;
- case "leave" :
- closeOldMenu();
- break;
- }
- };
- this.apartment0Processor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "leave" :
- HUD.hungerLoss = (float) (timeSlept * (HUD.METABOLISM / HUD.gameSlowFactor) / 2);
- HUD.health -= (HUD.hungerPain * timeSlept) / 6;
- HUD.hunger -= (double) HUD.hungerLoss;
- Inventory.dirtyClothes();
- closeResultMenu();
- try {
- cityNoise.play();
- } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- break;
- }
- };
- apartmentArchive = new MenuDataArchive(apartmentPrompt, apartmentOptions, apartmentProcessor, ID.ChoiceMenu, apartmentTitle);
- apartment0Archive = new MenuDataArchive(apartment0Prompt, apartment0Options, apartment0Processor, ID.ResultMenu, null);
- this.collegeProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "payTuition" :
- System.out.println("TUITION");
- try {
- resultMenu = new Menu(college0Archive);
- } catch (FontFormatException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- makeResultMenu();
- closeOldMenu();
- break;
- case "leave":
- closeOldMenu();
- break;
- }
- };
- collegeArchive = new MenuDataArchive(collegePrompt, collegeOptions, collegeProcessor, ID.ChoiceMenu, collegeTitle);
- this.college0Processor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "leave" :
- closeResultMenu();
- break;
- }
- };
- college0Archive = new MenuDataArchive(college0Prompt, college0Options, college0Processor, ID.ResultMenu, null);
- this.walmartProcessor = (String choiceIDPr) -> {
- switch(choiceIDPr) {
- case "buy1Grocery":
- if (Finance.tryBuy(10.00)) {
- HUD.hunger += 25; //placeholder
- closeOldMenu();
- } else {
- //play sound
- }
- break;
- case "buy7Grocery":
- if (Finance.tryBuy(40.00)) {
- HUD.hunger += 100;
- closeOldMenu();
- } else {
- //play sound
- }
- break;
- case "buyBike":
- if (Finance.tryBuy(100.00)) {
- Inventory.hasBike = true;
- //HUD.bike = true;
- closeOldMenu();
- } else {
- //play sound
- }
- break;
- case "leave":
- closeOldMenu();
- break;
- }
- };
- walmartArchive = new MenuDataArchive(walmartPrompt, walmartOptions, walmartProcessor, ID.ChoiceMenu, walmartTitle);
- this.hospitalProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "checkUp":
- if (Finance.tryBuy(500.00)) {
- HUD.health = 100;
- HUD.rawTimeElapsed += 2 * 60 * HUD.gameSlowFactor; //takes one hour to complete
- try {
- resultMenu = new Menu(hospital0Archive);
- } catch (FontFormatException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- makeResultMenu();
- closeOldMenu();
- } else {
- //play sound
- }
- break;
- case "leave":
- closeOldMenu();
- break;
- }
- };
- hospitalArchive = new MenuDataArchive(hospitalPrompt, hospitalOptions, hospitalProcessor, ID.ChoiceMenu, hospitalTitle);
- this.hospital0Processor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "leave" :
- closeResultMenu();
- break;
- }
- };
- hospital0Archive = new MenuDataArchive(hospital0Prompt, hospital0Options, hospital0Processor, ID.ResultMenu, null);
- eventFindMoneyProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "leave":
- double rng = r.nextInt(100);
- double foundMoney = rng / 100;
- if (foundMoney == 0) {
- foundMoney = .01;
- }
- HUD.money += foundMoney;
- closeEvent();
- break;
- }
- };
- eventFindMoneyArchive = new MenuDataArchive(eventFindMoneyPrompt, eventFindMoneyOptions,
- eventFindMoneyProcessor, ID.ResultMenu, null);
- this.eventStrikesProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "exitStrikes" :
- closeEvent();
- break;
- }
- };
- eventStrikesArchive = new MenuDataArchive(eventStrikesPrompt, eventStrikesOptions,
- eventStrikesProcessor, ID.ResultMenu, null);
- eventCollapseProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "collapse":
- try {
- cityNoise.stop();
- } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) {
- e.printStackTrace();
- }
- if ((HUD.money > 0)) { //if you have any money, make the result menu where you lose money
- try {
- resultMenu = new Menu(eventCollapse0Archive);
- } catch (FontFormatException | IOException e) {
- e.printStackTrace();
- }
- } else {
- try { //else make the result menu where you lose moeny
- resultMenu = new Menu(eventCollapse0NoMoneyArchive);
- } catch (FontFormatException | IOException e) {
- e.printStackTrace();
- }
- }
- sleepEffect = new SleepEffect(0, 0, ID.SleepEffect);
- Game.handler.addObject(sleepEffect);
- Game.gameState = Game.STATES.Sleeping;
- if (HUD.hoursSinceMidnight > 6) {
- nextMorning = (int) ((8 * 60 * HUD.gameSlowFactor) + (HUD.day * 1440 * HUD.gameSlowFactor) - 1);
- } else {
- nextMorning = (int) ((8 * 60 * HUD.gameSlowFactor) + ((HUD.day - 1) * 1440 * HUD.gameSlowFactor) - 1);
- }
- //player wakes up at 7:59 AM so they have time to make their 8 AM rent payment
- timeSlept = (int) (nextMorning - HUD.rawTimeElapsed);
- HUD.energy += SleepEffect.getEnergyRestored();
- HUD.rawTimeElapsed = nextMorning; //set gameTime to the next morning
- makeResultMenu();
- closeEvent();
- System.out.println("oh boy i cant wait to make result menu");
- break;
- }
- };
- eventCollapseArchive = new MenuDataArchive(eventCollapsePrompt, eventCollapseOptions,
- eventCollapseProcessor, ID.ResultMenu, null);
- eventCollapse0Processor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "leave":
- HUD.hungerLoss = (float) (timeSlept * (HUD.METABOLISM / HUD.gameSlowFactor) / 2);
- HUD.health -= (HUD.hungerPain * timeSlept) / 6;
- HUD.hunger -= (double) HUD.hungerLoss;
- HUD.money -= HUD.money / 2; //lose half your money
- Game.moneyChangeCause = "Stolen";
- //moneyEffectML = new MoneyEffect(10, 85, ID.MoneyEffect, -HUD.money / 2);
- System.out.println(moneyEffectML + " = moneyEffectML");
- Inventory.dirtyClothes();
- System.out.println("Wake up from Collapse Menu");
- try {
- stream = AudioSystem.getAudioInputStream(PlayerInput.class.getResource("cityAmbience.wav"));
- clip = AudioSystem.getClip();
- cityNoise = new BackGroundSound((long) 0.0, clip, "?", stream, filePathSound);
- cityNoise.play();
- } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- closeResultMenu();
- System.out.println(moneyEffectML + " = moneyEffectML");
- break;
- }
- };
- eventCollapse0Archive = new MenuDataArchive(eventCollapse0Prompt, eventCollapse0Options,
- eventCollapse0Processor, ID.ResultMenu, null);
- eventCollapse0NoMoneyProcessor = (String choiceIDPr) -> {
- switch (choiceIDPr) {
- case "leave":
- HUD.hungerLoss = (float) (timeSlept * (HUD.METABOLISM / HUD.gameSlowFactor) / 2);
- HUD.health -= (HUD.hungerPain * timeSlept) / 6;
- HUD.hunger -= (double) HUD.hungerLoss;
- Inventory.dirtyClothes();
- System.out.println("Wake up from Collapse Menu");
- try {
- stream = AudioSystem.getAudioInputStream(PlayerInput.class.getResource("cityAmbience.wav"));
- clip = AudioSystem.getClip();
- cityNoise = new BackGroundSound((long) 0.0, clip, "?", stream, filePathSound);
- cityNoise.play();
- } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- closeResultMenu();
- break;
- }
- };
- eventCollapse0NoMoneyArchive = new MenuDataArchive(eventCollapse0NoMoneyPrompt, eventCollapse0NoMoneyOptions,
- eventCollapse0NoMoneyProcessor, ID.ResultMenu, null);
- kickedOutProcessor = (choiceIDPr) -> {
- switch (choiceIDPr) {
- case "leave":
- closeOldMenu();
- break;
- }
- };
- kickedOutArchive = new MenuDataArchive(kickedOutPrompt, kickedOutOptions, kickedOutProcessor, ID.ResultMenu, null);
- } // END OF BOX CONSTRUCTOR
- public void closeResultMenu() {
- Game.thisGame.removeKeyListener(resultMenu);
- Game.handler.removeObject(resultMenu);
- resultMenu = null;
- Game.gameState = Game.STATES.Playing;
- }
- public void closeOldMenu() {
- Game.handler.removeObject(Game.activeListener.getBuildingMenu());
- Game.thisGame.removeKeyListener(Game.activeListener.getBuildingMenu());
- if (resultMenu == null) {
- Game.gameState = Game.STATES.Playing;
- }
- }
- public void makeResultMenu() {
- Game.handler.addObject(resultMenu);
- Game.thisGame.addKeyListener(resultMenu);
- }
- public void closeEvent() {
- Game.handler.removeObject(Game.eventMaker.eventMenu);
- Game.thisGame.removeKeyListener(Game.eventMaker.eventMenu);
- if (resultMenu == null) {
- Game.gameState = Game.STATES.Playing;
- }
- Game.eventMaker.eventMenu = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement