IEnumerator DialogueCoroutine(Dialogue d, string colorString = "") { dialogueManager.SetColor(colorString); dialogueManager.ClearDialogue(); dialogueManager.AddDialogue(d); gameState = GameState.CUTSCENE; dialogueManager.DisplayNextSentence(); yield return(dialogueManager.WaitForCaughtUpTextAndInput()); gameState = GameState.OVERWORLD; dialogueManager.SetDisplay(false); }
IEnumerator BattleHandler() { allyPokemon = Player.instance.party.GetFirstNonFaintedPokemon(); allyHPSlider.value = allyPokemon.HP; dialogueManager.ClearDialogue(); dialogueManager.AddDialogue("Foe " + foePokemon.GetName() + " wants to battle!"); allyParent.transform.localPosition = new Vector3(600, -32, 0); dialogueManager.DisplayNextSentence(); foePokemonParent.transform.localPosition = Vector3.zero; for (int i = 600; i >= 0; i -= 10) { foeParent.transform.localPosition = new Vector3(-i, 96, 0); yield return(null); } bool partyDead = false; while (Player.instance.party.HasUsablePokemon() && !foePokemon.CheckForDeath()) { bool allyDied = false; bool foeDied = false; allyParent.transform.localPosition = new Vector3(600, -32, 0); allyPokemon = Player.instance.party.GetFirstNonFaintedPokemon(); dialogueManager.AddDialogue("Go, " + allyPokemon.GetName() + "!"); yield return(dialogueManager.WaitForCaughtUpText()); allyPokemonParent.transform.localPosition = Vector3.zero; for (int i = 500; i >= 0; i -= 10) { allyParent.transform.localPosition = new Vector3(i, -32, 0); yield return(null); } while (!allyPokemon.CheckForDeath() && !foePokemon.CheckForDeath()) { int foeRand = Random.Range(0, foePokemon.GetNumberOfMoves()); int allyRand = Random.Range(0, allyPokemon.GetNumberOfMoves()); Pokemon fasterPokemon; Pokemon slowerPokemon; if (allyPokemon.speed > foePokemon.speed) { fasterPokemon = allyPokemon; slowerPokemon = foePokemon; } else { fasterPokemon = foePokemon; slowerPokemon = allyPokemon; } yield return(StartCoroutine(SingleAttack(fasterPokemon, slowerPokemon, foeRand))); int check = CheckIfEitherPokemonDied(); if (check != 0) { allyDied = (check == 1); foeDied = (check == 2); break; } yield return(StartCoroutine(SingleAttack(slowerPokemon, fasterPokemon, allyRand))); check = CheckIfEitherPokemonDied(); if (check != 0) { allyDied = (check == 1); foeDied = (check == 2); break; } } if (foeDied) { int exp = ExperienceCalculation(allyPokemon, foePokemon); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); for (int i = 0; i < 150; i += 10) { foePokemonParent.transform.localPosition = new Vector3(0, -i, 0); yield return(null); } dialogueManager.AddDialogue(foePokemon.GetName() + " fainted!"); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue(allyPokemon.GetName() + " gained " + exp + " experience points!"); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); allyPokemon.ModXP(exp); yield return(StartCoroutine(WaitForBarsToLoad())); break; } if (allyDied) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); for (int i = 0; i < 150; i += 10) { allyPokemonParent.transform.localPosition = new Vector3(0, -i, 0); yield return(null); } dialogueManager.AddDialogue(allyPokemon.GetName() + " fainted!"); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); if (!Player.instance.party.HasUsablePokemon()) { partyDead = true; } } } if (partyDead) { dialogueManager.AddDialogue(Player.instance.name + " is out of usable Pokemon!"); dialogueManager.AddDialogue(Player.instance.name + " blacked out!"); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); } //dialogueManager.AddDialogue("BATTLE OVER"); PokemonGameManager.instance.EndBattle(); }