public IEnumerator interact() { if (PlayerMovement.player.setCheckBusyWith(this.gameObject)) { StartCoroutine(Dialog.drawSignBox(signTint)); if (printTextMethod == DialogBoxHandler.PrintTextMethod.Typewriter) { StartCoroutine(Dialog.drawTextSilent(signText)); } else if (printTextMethod == DialogBoxHandler.PrintTextMethod.Instant) { Dialog.drawTextInstant(signText); } yield return(null); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back") && Input.GetAxisRaw("Horizontal") == 0 && Input.GetAxisRaw("Vertical") >= 0) { yield return(null); } StartCoroutine(Dialog.undrawSignBox()); yield return(null); PlayerMovement.player.unsetCheckBusyWith(this.gameObject); } }
public IEnumerator control() { //sceneTransition.FadeIn(); StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.defaultSpeed)); running = true; switching = false; swapPosition = -1; currentPosition = 0; SaveData.currentSave.PC.packParty(); updateParty(); updateFrames(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); StartCoroutine("animateIcons"); while (running) { if (Input.GetAxisRaw("Horizontal") > 0) { if (currentPosition < 6) { shiftPosition(1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetAxisRaw("Horizontal") < 0) { if (currentPosition > 0) { shiftPosition(-1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetAxisRaw("Vertical") > 0) { if (currentPosition > 0) { if (currentPosition == 6) { shiftPosition(-1); } else { shiftPosition(-2); } SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetAxisRaw("Vertical") < 0) { if (currentPosition < 6) { shiftPosition(2); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetButton("Select")) { if (currentPosition == 6) { if (switching) { switching = false; swapPosition = -1; updateFrames(); Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); yield return(new WaitForSeconds(0.2f)); } else { SfxHandler.Play(selectClip); running = false; } } else if (switching) { if (currentPosition == swapPosition) { switching = false; swapPosition = -1; updateFrames(); Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); yield return(new WaitForSeconds(0.2f)); } else { yield return(StartCoroutine(switchPokemon(swapPosition, currentPosition))); switching = false; swapPosition = -1; updateFrames(); Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); yield return(new WaitForSeconds(0.2f)); } } else { Pokemon selectedPokemon = SaveData.currentSave.PC.boxes[0][currentPosition]; int chosenIndex = -1; while (chosenIndex != 0) { string[] choices = new string[] { "Summary", "Switch", "Item", "Cancel" }; chosenIndex = -1; SfxHandler.Play(selectClip); Dialog.drawDialogBox(); Dialog.drawTextInstant("Do what with " + selectedPokemon.getName() + "?"); Dialog.drawChoiceBox(choices); yield return(new WaitForSeconds(0.2f)); yield return(StartCoroutine(Dialog.choiceNavigate(choices))); chosenIndex = Dialog.chosenIndex; if (chosenIndex == 3) { //Summary SfxHandler.Play(selectClip); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); //Set SceneSummary to be active so that it appears Scene.main.Summary.gameObject.SetActive(true); StartCoroutine(Scene.main.Summary.control(SaveData.currentSave.PC.boxes[0], currentPosition)); //Start an empty loop that will only stop when SceneSummary is no longer active (is closed) while (Scene.main.Summary.gameObject.activeSelf) { yield return(null); } chosenIndex = 0; Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } else if (chosenIndex == 2) { //Switch switching = true; swapPosition = currentPosition; updateFrames(); chosenIndex = 0; Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Move " + selectedPokemon.getName() + " to where?"); yield return(new WaitForSeconds(0.2f)); } else if (chosenIndex == 1) { //Item Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); if (!string.IsNullOrEmpty(selectedPokemon.getHeldItem())) { yield return (StartCoroutine( Dialog.drawText(selectedPokemon.getName() + " is holding " + selectedPokemon.getHeldItem() + "."))); choices = new string[] { "Swap", "Take", "Cancel" }; chosenIndex = -1; Dialog.drawChoiceBox(choices); yield return(new WaitForSeconds(0.2f)); yield return(StartCoroutine(Dialog.choiceNavigate(choices))); chosenIndex = Dialog.chosenIndex; if (chosenIndex == 2) { //Swap SfxHandler.Play(selectClip); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); Scene.main.Bag.gameObject.SetActive(true); StartCoroutine(Scene.main.Bag.control(false, true)); while (Scene.main.Bag.gameObject.activeSelf) { yield return(null); } string chosenItem = Scene.main.Bag.chosenItem; Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); if (string.IsNullOrEmpty(chosenItem)) { Dialog.drawTextInstant("Choose a Pokémon."); } //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); if (!string.IsNullOrEmpty(chosenItem)) { Dialog.drawDialogBox(); yield return (StartCoroutine( Dialog.drawText("Swap " + selectedPokemon.getHeldItem() + " for " + chosenItem + "?"))); Dialog.drawChoiceBox(); yield return(StartCoroutine(Dialog.choiceNavigate())); chosenIndex = Dialog.chosenIndex; Dialog.undrawChoiceBox(); if (chosenIndex == 1) { string receivedItem = selectedPokemon.swapHeldItem(chosenItem); SaveData.currentSave.Bag.addItem(receivedItem, 1); SaveData.currentSave.Bag.removeItem(chosenItem, 1); Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", "Gave " + chosenItem + " to " + selectedPokemon.getName() + ",")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", "and received " + receivedItem + " in return.")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } } } else if (chosenIndex == 1) { //Take Dialog.undrawChoiceBox(); string receivedItem = selectedPokemon.swapHeldItem(""); SaveData.currentSave.Bag.addItem(receivedItem, 1); updateParty(); updateFrames(); Dialog.drawDialogBox(); yield return (StartCoroutine( Dialog.drawText("Took " + receivedItem + " from " + selectedPokemon.getName() + "."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } } else { yield return (StartCoroutine( Dialog.drawText(selectedPokemon.getName() + " isn't holding anything."))); choices = new string[] { "Give", "Cancel" }; chosenIndex = -1; Dialog.drawChoiceBox(choices); yield return(new WaitForSeconds(0.2f)); yield return(StartCoroutine(Dialog.choiceNavigate(choices))); chosenIndex = Dialog.chosenIndex; if (chosenIndex == 1) { //Give SfxHandler.Play(selectClip); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); Scene.main.Bag.gameObject.SetActive(true); StartCoroutine(Scene.main.Bag.control(false, true)); while (Scene.main.Bag.gameObject.activeSelf) { yield return(null); } string chosenItem = Scene.main.Bag.chosenItem; Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); if (string.IsNullOrEmpty(chosenItem)) { Dialog.drawTextInstant("Choose a Pokémon."); } //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); if (!string.IsNullOrEmpty(chosenItem)) { selectedPokemon.swapHeldItem(chosenItem); SaveData.currentSave.Bag.removeItem(chosenItem, 1); updateParty(); updateFrames(); Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", "Gave " + chosenItem + " to " + selectedPokemon.getName() + ".")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } } } chosenIndex = 0; yield return(new WaitForSeconds(0.2f)); } } if (!switching) { Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); } } } else if (Input.GetButton("Back")) { if (switching) { switching = false; swapPosition = -1; updateFrames(); Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); yield return(new WaitForSeconds(0.2f)); } else { currentPosition = 6; updateFrames(); SfxHandler.Play(selectClip); running = false; } } yield return(null); } StopCoroutine("animateIcons"); //yield return new WaitForSeconds(sceneTransition.FadeOut()); yield return(StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed))); GlobalVariables.global.resetFollower(); this.gameObject.SetActive(false); }
public IEnumerator interact() { if (PlayerMovement.player.direction == 0) { if (PlayerMovement.player.setCheckBusyWith(this.gameObject)) { spriteLight.enabled = true; PClight.enabled = true; SfxHandler.Play(onClip); yield return(StartCoroutine("onAnim")); Dialog.drawDialogBox(); yield return(Dialog.StartCoroutine("drawTextSilent", SaveData.currentSave.playerName + " turned on the PC!")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } int accessedPC = -1; while (accessedPC != 0) { Dialog.drawDialogBox(); yield return(Dialog.StartCoroutine("drawText", "Which PC should be accessed?")); if (SaveData.currentSave.getCVariable("meetBill") != 1) //for use in fangames possibly? { Dialog.drawChoiceBox(new string[] { "Someone's", "Switch off" }); } else { Dialog.drawChoiceBox(new string[] { "Bill's", "Switch off" }); } yield return(Dialog.StartCoroutine("choiceNavigate")); Dialog.undrawChoiceBox(); accessedPC = Dialog.chosenIndex; int accessedBox = -1; if (accessedPC != 0) { //if not turning off computer Dialog.drawDialogBox(); SfxHandler.Play(openClip); yield return (Dialog.StartCoroutine("drawTextSilent", "The Pokémon Storage System \\was accessed.")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } while (accessedBox != 0 && accessedPC != 0) { //if not turning off computer string[] choices = new string[] { "Move", "Log off" }; string[] choicesFlavour = new string[] { "You may rearrange Pokémon in and \\between your party and Boxes.", "Log out of the Pokémon Storage \\System." }; Dialog.drawChoiceBox(choices); Dialog.drawDialogBox(); Dialog.drawTextInstant(choicesFlavour[0]); yield return(new WaitForSeconds(0.2f)); yield return(StartCoroutine(Dialog.choiceNavigate(choices, choicesFlavour))); accessedBox = Dialog.chosenIndex; //SceneTransition sceneTransition = Dialog.transform.GetComponent<SceneTransition>(); if (accessedBox == 1) { //access Move SfxHandler.Play(selectClip); StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed)); yield return(new WaitForSeconds(ScreenFade.defaultSpeed + 0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f) + 0.4f); SfxHandler.Play(openClip); //Set ScenePC to be active so that it appears Scene.main.PC.gameObject.SetActive(true); StartCoroutine(Scene.main.PC.control()); //Start an empty loop that will only stop when ScenePC is no longer active (is closed) while (Scene.main.PC.gameObject.activeSelf) { yield return(null); } yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); } Dialog.undrawChoiceBox(); } } } Dialog.undrawDialogBox(); spriteLight.enabled = false; PClight.enabled = false; SfxHandler.Play(offClip); yield return(new WaitForSeconds(0.2f)); PlayerMovement.player.unsetCheckBusyWith(this.gameObject); } } }