private IEnumerator LearnMove(Pokemon selectedPokemon, string move) { int chosenIndex = 1; if (chosenIndex == 1) { bool learning = true; while (learning) { //Moveset is full if (selectedPokemon.getMoveCount() == 4) { dialog.DrawDialogBox(); yield return (StartCoroutine( dialog.DrawText(selectedPokemon.getName() + " wants to learn the \nmove " + move + "."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.DrawDialogBox(); yield return (StartCoroutine( dialog.DrawText("However, " + selectedPokemon.getName() + " already \nknows four moves."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.DrawDialogBox(); yield return (StartCoroutine(dialog.DrawText("Should a move be deleted and \nreplaced with " + move + "?"))); yield return(StartCoroutine(dialog.DrawChoiceBox())); chosenIndex = dialog.chosenIndex; dialog.UndrawChoiceBox(); if (chosenIndex == 1) { dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawText("Which move should \nbe forgotten?"))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } yield return(StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed))); //Set SceneSummary to be active so that it appears Scene.main.Summary.gameObject.SetActive(true); StartCoroutine(Scene.main.Summary.control(selectedPokemon, move)); //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); } string replacedMove = Scene.main.Summary.replacedMove; yield return(StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.defaultSpeed))); if (!string.IsNullOrEmpty(replacedMove)) { dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawTextSilent("1, "))); yield return(new WaitForSeconds(0.4f)); yield return(StartCoroutine(dialog.DrawTextSilent("2, "))); yield return(new WaitForSeconds(0.4f)); yield return(StartCoroutine(dialog.DrawTextSilent("and... "))); yield return(new WaitForSeconds(0.4f)); yield return(StartCoroutine(dialog.DrawTextSilent("... "))); yield return(new WaitForSeconds(0.4f)); yield return(StartCoroutine(dialog.DrawTextSilent("... "))); yield return(new WaitForSeconds(0.4f)); SfxHandler.Play(forgetMoveClip); yield return(StartCoroutine(dialog.DrawTextSilent("Poof!"))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.DrawDialogBox(); yield return (StartCoroutine( dialog.DrawText(selectedPokemon.getName() + " forgot how to \nuse " + replacedMove + "."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawText("And..."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.DrawDialogBox(); AudioClip mfx = Resources.Load <AudioClip>("Audio/mfx/GetAverage"); BgmHandler.main.PlayMFX(mfx); StartCoroutine(dialog.DrawTextSilent(selectedPokemon.getName() + " learned \n" + move + "!")); yield return(new WaitForSeconds(mfx.length)); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.UndrawDialogBox(); learning = false; } else { //give up? chosenIndex = 0; } } if (chosenIndex == 0) { //NOT ELSE because this may need to run after (chosenIndex == 1) runs dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawText("Give up on learning the move \n" + move + "?"))); yield return(StartCoroutine(dialog.DrawChoiceBox())); chosenIndex = dialog.chosenIndex; dialog.UndrawChoiceBox(); if (chosenIndex == 1) { learning = false; chosenIndex = 0; } } } //Moveset is not full, can fit the new move easily else { selectedPokemon.addMove(move); dialog.DrawDialogBox(); AudioClip mfx = Resources.Load <AudioClip>("Audio/mfx/GetAverage"); BgmHandler.main.PlayMFX(mfx); StartCoroutine(dialog.DrawTextSilent(selectedPokemon.getName() + " learned \n" + move + "!")); yield return(new WaitForSeconds(mfx.length)); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.UndrawDialogBox(); learning = false; } } } if (chosenIndex == 0) { //NOT ELSE because this may need to run after (chosenIndex == 1) runs //cancel learning loop dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawText(selectedPokemon.getName() + " did not learn \n" + move + "."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } }
public IEnumerator control() { selectedIcon = 0; setSelectedText(""); SfxHandler.Play(openClip); yield return(StartCoroutine(openAnim())); running = true; while (running) { if (SaveData.currentSave.getCVariable("NewPause") == 1) { if (Input.GetAxisRaw("Vertical") != 0 || Input.GetAxisRaw("Horizontal") != 0) { directions.SetActive(false); if (Input.GetAxisRaw("Vertical") > 0) { if (selectedIcon == 0) { selectedIcon = 2; } else if (selectedIcon > 3) { selectedIcon -= 3; } } else if (Input.GetAxisRaw("Horizontal") < 0) { if (selectedIcon == 0) { selectedIcon = 1; } if (selectedIcon != 1 && selectedIcon != 4) { selectedIcon -= 1; } } else if (Input.GetAxisRaw("Vertical") < 0) { if (selectedIcon == 0) { selectedIcon = 5; } if (selectedIcon < 4) { selectedIcon += 3; } } else if (Input.GetAxisRaw("Horizontal") > 0) { if (selectedIcon == 0) { selectedIcon = 3; } else if (selectedIcon != 3 && selectedIcon != 6) { selectedIcon += 1; } } StartCoroutine(updateIcon(selectedIcon)); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } else if (Input.GetButton("Select")) { if (selectedIcon == 1) { //Pokedex GlobalVariables.global.debug("Pokédex not yet implemented"); yield return(new WaitForSeconds(0.2f)); } else if (selectedIcon == 2) { //Party SfxHandler.Play(selectClip); //StartCoroutine(fadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Party.gameObject))); //StartCoroutine(unfadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } else if (selectedIcon == 3) { //Bag SfxHandler.Play(selectClip); //StartCoroutine(fadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Bag.gameObject))); //StartCoroutine(unfadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } else if (selectedIcon == 4) { //TrainerCard SfxHandler.Play(selectClip); //StartCoroutine(fadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Trainer.gameObject))); //StartCoroutine(unfadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } else if (selectedIcon == 5) { //Save saveDataDisplay.gameObject.SetActive(true); saveDataDisplay.sprite = Resources.Load <Sprite>("Frame/choice" + PlayerPrefs.GetInt("frameStyle")); int badgeTotal = 0; for (int i = 0; i < 12; i++) { if (SaveData.currentSave.gymsBeaten[i]) { badgeTotal += 1; } } string playerTime = "" + SaveData.currentSave.playerMinutes; if (playerTime.Length == 1) { playerTime = "0" + playerTime; } playerTime = SaveData.currentSave.playerHours + " : " + playerTime; mapName.text = PlayerMovement.player.accessedMapSettings.mapName; dataText.text = SaveData.currentSave.playerName + "\n" + badgeTotal + "\n" + "0" + "\n" + //pokedex not yet implemented playerTime; mapNameShadow.text = mapName.text; dataTextShadow.text = dataText.text; Dialog.DrawDialogBox(); yield return(StartCoroutine(Dialog.DrawText("Would you like to save the game?"))); yield return(StartCoroutine(Dialog.DrawChoiceBox(0))); int chosenIndex = Dialog.chosenIndex; if (chosenIndex == 1) { //update save file //Dialog.UndrawChoiceBox(); SaveData.currentSave.levelName = Application.loadedLevelName; SaveData.currentSave.playerPosition = new SeriV3(PlayerMovement.player.transform.position); SaveData.currentSave.playerDirection = PlayerMovement.player.direction; SaveData.currentSave.mapName = PlayerMovement.player.accessedMapSettings.mapName; NonResettingHandler.saveDataToGlobal(); SaveLoad.Save(); Dialog.DrawDialogBox(); yield return (StartCoroutine(Dialog.DrawText(SaveData.currentSave.playerName + " saved the game!"))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } Dialog.UndrawDialogBox(); Dialog.UndrawChoiceBox(); saveDataDisplay.gameObject.SetActive(false); yield return(new WaitForSeconds(0.2f)); } else if (selectedIcon == 6) { //Settings SfxHandler.Play(selectClip); //StartCoroutine(fadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Settings.gameObject))); //StartCoroutine(unfadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } } if (Input.GetButton("Start") || Input.GetButton("Back")) { running = false; } yield return(null); } else { if (Input.GetAxisRaw("Vertical") != 0 || Input.GetAxisRaw("Horizontal") != 0) { if (Input.GetAxisRaw("Horizontal") < 0) { if (selectedIcon == 6 || selectedIcon == 0) { SfxHandler.Play(selectClip); selectedIcon = 5; } } else if (Input.GetAxisRaw("Horizontal") > 0) { if (selectedIcon == 5 || selectedIcon == 0) { SfxHandler.Play(selectClip); selectedIcon = 6; } } StartCoroutine(updateIcon(selectedIcon)); yield return(new WaitForSeconds(0.2f)); } else if (Input.GetButton("Select")) { if (selectedIcon == 5) { //Save saveDataDisplay.gameObject.SetActive(true); saveDataDisplay.sprite = Resources.Load <Sprite>("Frame/choice" + PlayerPrefs.GetInt("frameStyle")); int badgeTotal = 0; for (int i = 0; i < 12; i++) { if (SaveData.currentSave.gymsBeaten[i]) { badgeTotal += 1; } } string playerTime = "" + SaveData.currentSave.playerMinutes; if (playerTime.Length == 1) { playerTime = "0" + playerTime; } playerTime = SaveData.currentSave.playerHours + " : " + playerTime; mapName.text = PlayerMovement.player.accessedMapSettings.mapName; dataText.text = SaveData.currentSave.playerName + "\n" + badgeTotal + "\n" + "0" + "\n" + //pokedex not yet implemented playerTime; mapNameShadow.text = mapName.text; dataTextShadow.text = dataText.text; Dialog.DrawDialogBox(); yield return(StartCoroutine(Dialog.DrawText("Would you like to save the game?"))); yield return(StartCoroutine(Dialog.DrawChoiceBox(0))); int chosenIndex = Dialog.chosenIndex; if (chosenIndex == 1) { //update save file Dialog.UndrawChoiceBox(); Dialog.UndrawDialogBox(); SaveData.currentSave.levelName = Application.loadedLevelName; SaveData.currentSave.playerPosition = new SeriV3(PlayerMovement.player.transform.position); SaveData.currentSave.playerDirection = PlayerMovement.player.direction; SaveData.currentSave.mapName = PlayerMovement.player.accessedMapSettings.mapName; NonResettingHandler.saveDataToGlobal(); SaveLoad.Save(); yield return (StartCoroutine(Dialog.DrawText(SaveData.currentSave.playerName + " saved the game!"))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } Dialog.UndrawDialogBox(); Dialog.UndrawChoiceBox(); saveDataDisplay.gameObject.SetActive(false); yield return(new WaitForSeconds(0.2f)); } else if (selectedIcon == 6) { //Settings SfxHandler.Play(selectClip); //StartCoroutine(fadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); pauseBottom.gameObject.SetActive(false); generic.gameObject.SetActive(false); yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Settings.gameObject))); pauseBottom.gameObject.SetActive(true); generic.gameObject.SetActive(true); //StartCoroutine(unfadeIcons(0.4f)); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } } if (Input.GetButton("Start") || Input.GetButton("Back")) { running = false; } yield return(null); } } yield return(StartCoroutine(closeAnim())); pauseBottom.gameObject.SetActive(false); generic.gameObject.SetActive(false); }