private IEnumerator LearnMove(OwnedPokemon selectedPokemon, PokemonMove pMoveToLearn) { 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 " + pMoveToLearn.Name + "."))); 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 " + pMoveToLearn.Name + "?"))); 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 PKUScene.main.Summary.gameObject.SetActive(true); StartCoroutine(PKUScene.main.Summary.control(selectedPokemon, pMoveToLearn.Name)); //Start an empty loop that will only stop when SceneSummary is no longer active (is closed) while (PKUScene.main.Summary.gameObject.activeSelf) { yield return(null); } string replacedMove = PKUScene.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" + pMoveToLearn.Name + "!")); 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" + pMoveToLearn.Name + "?"))); 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.TryAddMove(pMoveToLearn); dialog.DrawDialogBox(); AudioClip mfx = Resources.Load <AudioClip>("Audio/mfx/GetAverage"); BgmHandler.main.PlayMFX(mfx); StartCoroutine(dialog.DrawTextSilent(selectedPokemon.GetName() + " learned \n" + pMoveToLearn + "!")); 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" + pMoveToLearn + "."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } }
public IEnumerator control(Pokemon pokemonToEvolve, string methodOfEvolution) { selectedPokemon = pokemonToEvolve; evolutionMethod = methodOfEvolution; evolutionID = selectedPokemon.getEvolutionID(evolutionMethod); string selectedPokemonName = selectedPokemon.getName(); pokemonSpriteAnimation = selectedPokemon.GetFrontAnim_(); evolutionSpriteAnimation = Pokemon.GetFrontAnimFromID_(evolutionID, selectedPokemon.getGender(), selectedPokemon.getIsShiny()); pokemonSprite.sprite = pokemonSpriteAnimation[0]; evolutionSprite.sprite = evolutionSpriteAnimation[0]; StartCoroutine(animatePokemon()); pokemonSprite.rectTransform.sizeDelta = new Vector2(128, 128); evolutionSprite.rectTransform.sizeDelta = new Vector2(0, 0); pokemonSprite.color = new Color(0.5f, 0.5f, 0.5f, 0.5f); evolutionSprite.color = new Color(0.5f, 0.5f, 0.5f, 0.5f); topBorder.rectTransform.sizeDelta = new Vector2(342, 0); bottomBorder.rectTransform.sizeDelta = new Vector2(342, 0); glow.rectTransform.sizeDelta = new Vector2(0, 0); stopAnimations = false; StartCoroutine(ScreenFade.main.Fade(true, 1f)); yield return(new WaitForSeconds(1f)); dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawText("What?"))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } yield return(StartCoroutine(dialog.DrawText("\n" + selectedPokemon.getName() + " is evolving!"))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.UndrawDialogBox(); evolving = true; AudioClip cry = selectedPokemon.GetCry(); SfxHandler.Play(cry); yield return(new WaitForSeconds(cry.length)); BgmHandler.main.PlayOverlay(evolutionBGM, 753100); yield return(new WaitForSeconds(0.4f)); c_animateEvolution = StartCoroutine(animateEvolution()); SfxHandler.Play(evolvingClip); yield return(new WaitForSeconds(0.4f)); while (evolving) { if (Input.GetButtonDown("Back")) { evolving = false; //fadeTime = sceneTransition.FadeOut(); //yield return new WaitForSeconds(fadeTime); yield return(StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed))); stopAnimateEvolution(); //fadeTime = sceneTransition.FadeIn(); //yield return new WaitForSeconds(fadeTime); yield return(StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.defaultSpeed))); dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawText("Huh?"))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } yield return(StartCoroutine(dialog.DrawText("\n" + selectedPokemon.getName() + " stopped evolving."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.UndrawDialogBox(); } yield return(null); } if (evolved) { selectedPokemon.evolve(evolutionMethod); yield return(new WaitForSeconds(3.2f)); cry = selectedPokemon.GetCry(); BgmHandler.main.PlayMFX(cry); yield return(new WaitForSeconds(cry.length)); AudioClip evoMFX = Resources.Load <AudioClip>("Audio/mfx/GetGreat"); BgmHandler.main.PlayMFXConsecutive(evoMFX); dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawTextSilent("Congratulations!"))); yield return(new WaitForSeconds(0.8f)); StartCoroutine( dialog.DrawTextSilent("\nYour " + selectedPokemonName + " evolved into " + PokemonDatabase.getPokemon(evolutionID).getName() + "!")); //wait for MFX to stop float extraTime = (evoMFX.length - 0.8f > 0) ? evoMFX.length - 0.8f : 0; yield return(new WaitForSeconds(extraTime)); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } string newMove = selectedPokemon.MoveLearnedAtLevel(selectedPokemon.getLevel()); if (!string.IsNullOrEmpty(newMove) && !selectedPokemon.HasMove(newMove)) { yield return(StartCoroutine(LearnMove(selectedPokemon, newMove))); } dialog.UndrawDialogBox(); bool running = true; while (running) { if (Input.GetButtonDown("Select") || Input.GetButtonDown("Back")) { running = false; } yield return(null); } yield return(new WaitForSeconds(0.4f)); } StartCoroutine(ScreenFade.main.Fade(false, 1f)); BgmHandler.main.ResumeMain(1.2f); yield return(new WaitForSeconds(1.2f)); this.gameObject.SetActive(false); }
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); }