Ejemplo n.º 1
0
    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);
            }
        }
    }