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);
    }
Exemple #2
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);
            }
        }
    }