public IEnumerator control()
    {
        //sceneTransition.FadeIn();
        StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.defaultSpeed));

        running         = true;
        switching       = false;
        swapPosition    = -1;
        currentPosition = 0;
        SaveData.currentSave.PC.packParty();
        updateParty();
        updateFrames();
        Dialog.drawDialogBox();
        Dialog.drawTextInstant("Choose a Pokémon.");
        StartCoroutine("animateIcons");
        while (running)
        {
            if (Input.GetAxisRaw("Horizontal") > 0)
            {
                if (currentPosition < 6)
                {
                    shiftPosition(1);
                    SfxHandler.Play(selectClip);
                    yield return(new WaitForSeconds(0.2f));
                }
            }
            else if (Input.GetAxisRaw("Horizontal") < 0)
            {
                if (currentPosition > 0)
                {
                    shiftPosition(-1);
                    SfxHandler.Play(selectClip);
                    yield return(new WaitForSeconds(0.2f));
                }
            }
            else if (Input.GetAxisRaw("Vertical") > 0)
            {
                if (currentPosition > 0)
                {
                    if (currentPosition == 6)
                    {
                        shiftPosition(-1);
                    }
                    else
                    {
                        shiftPosition(-2);
                    }
                    SfxHandler.Play(selectClip);
                    yield return(new WaitForSeconds(0.2f));
                }
            }
            else if (Input.GetAxisRaw("Vertical") < 0)
            {
                if (currentPosition < 6)
                {
                    shiftPosition(2);
                    SfxHandler.Play(selectClip);
                    yield return(new WaitForSeconds(0.2f));
                }
            }
            else if (Input.GetButton("Select"))
            {
                if (currentPosition == 6)
                {
                    if (switching)
                    {
                        switching    = false;
                        swapPosition = -1;
                        updateFrames();
                        Dialog.undrawChoiceBox();
                        Dialog.drawDialogBox();
                        Dialog.drawTextInstant("Choose a Pokémon.");
                        yield return(new WaitForSeconds(0.2f));
                    }
                    else
                    {
                        SfxHandler.Play(selectClip);
                        running = false;
                    }
                }
                else if (switching)
                {
                    if (currentPosition == swapPosition)
                    {
                        switching    = false;
                        swapPosition = -1;
                        updateFrames();
                        Dialog.undrawChoiceBox();
                        Dialog.drawDialogBox();
                        Dialog.drawTextInstant("Choose a Pokémon.");
                        yield return(new WaitForSeconds(0.2f));
                    }
                    else
                    {
                        yield return(StartCoroutine(switchPokemon(swapPosition, currentPosition)));

                        switching    = false;
                        swapPosition = -1;
                        updateFrames();
                        Dialog.undrawChoiceBox();
                        Dialog.drawDialogBox();
                        Dialog.drawTextInstant("Choose a Pokémon.");
                        yield return(new WaitForSeconds(0.2f));
                    }
                }
                else
                {
                    OwnedPokemon selectedPokemon = SaveData.currentSave.PC.boxes[0][currentPosition];
                    int          chosenIndex     = -1;
                    while (chosenIndex != 0)
                    {
                        string[] choices = new string[]
                        {
                            "Summary", "Switch", "Item", "Cancel"
                        };
                        chosenIndex = -1;

                        SfxHandler.Play(selectClip);

                        Dialog.drawDialogBox();
                        Dialog.drawTextInstant("Do what with " + selectedPokemon.GetName() + "?");
                        Dialog.drawChoiceBox(choices);
                        yield return(new WaitForSeconds(0.2f));

                        yield return(StartCoroutine(Dialog.choiceNavigate(choices)));

                        chosenIndex = Dialog.chosenIndex;
                        if (chosenIndex == 3)
                        {
                            //Summary
                            SfxHandler.Play(selectClip);
                            //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f));
                            yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f)));

                            //Set SceneSummary to be active so that it appears
                            PKUScene.main.Summary.gameObject.SetActive(true);
                            StartCoroutine(PKUScene.main.Summary.control(SaveData.currentSave.PC.boxes[0], currentPosition));
                            //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);
                            }
                            chosenIndex = 0;
                            Dialog.undrawChoiceBox();
                            Dialog.drawDialogBox();
                            Dialog.drawTextInstant("Choose a Pokémon.");
                            //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f));
                            yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f)));
                        }
                        else if (chosenIndex == 2)
                        {
                            //Switch
                            switching    = true;
                            swapPosition = currentPosition;
                            updateFrames();
                            chosenIndex = 0;
                            Dialog.undrawChoiceBox();
                            Dialog.drawDialogBox();
                            Dialog.drawTextInstant("Move " + selectedPokemon.GetName() + " to where?");
                            yield return(new WaitForSeconds(0.2f));
                        }
                        else if (chosenIndex == 1)
                        {
                            //Item
                            Dialog.undrawChoiceBox();
                            Dialog.drawDialogBox();
                            if (!string.IsNullOrEmpty(selectedPokemon.getHeldItem()))
                            {
                                yield return
                                    (StartCoroutine(
                                         Dialog.drawText(selectedPokemon.GetName() + " is holding " +
                                                         selectedPokemon.getHeldItem() + ".")));

                                choices = new string[]
                                {
                                    "Swap", "Take", "Cancel"
                                };
                                chosenIndex = -1;
                                Dialog.drawChoiceBox(choices);
                                yield return(new WaitForSeconds(0.2f));

                                yield return(StartCoroutine(Dialog.choiceNavigate(choices)));

                                chosenIndex = Dialog.chosenIndex;

                                if (chosenIndex == 2)
                                {
                                    //Swap
                                    SfxHandler.Play(selectClip);
                                    //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f));
                                    yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f)));

                                    PKUScene.main.Bag.gameObject.SetActive(true);
                                    StartCoroutine(PKUScene.main.Bag.control(false, true));
                                    while (PKUScene.main.Bag.gameObject.activeSelf)
                                    {
                                        yield return(null);
                                    }

                                    string chosenItem = PKUScene.main.Bag.chosenItem;

                                    Dialog.undrawChoiceBox();
                                    Dialog.drawDialogBox();
                                    if (string.IsNullOrEmpty(chosenItem))
                                    {
                                        Dialog.drawTextInstant("Choose a Pokémon.");
                                    }
                                    //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f));
                                    yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f)));

                                    if (!string.IsNullOrEmpty(chosenItem))
                                    {
                                        Dialog.drawDialogBox();
                                        yield return
                                            (StartCoroutine(
                                                 Dialog.drawText("Swap " + selectedPokemon.getHeldItem() + " for " +
                                                                 chosenItem + "?")));

                                        Dialog.drawChoiceBox();
                                        yield return(StartCoroutine(Dialog.choiceNavigate()));

                                        chosenIndex = Dialog.chosenIndex;
                                        Dialog.undrawChoiceBox();

                                        if (chosenIndex == 1)
                                        {
                                            string receivedItem = selectedPokemon.swapHeldItem(chosenItem);
                                            SaveData.currentSave.Bag.addItem(receivedItem, 1);
                                            SaveData.currentSave.Bag.removeItem(chosenItem, 1);

                                            Dialog.drawDialogBox();
                                            yield return
                                                (Dialog.StartCoroutine("drawText",
                                                                       "Gave " + chosenItem + " to " + selectedPokemon.GetName() + ","));

                                            while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                                            {
                                                yield return(null);
                                            }
                                            Dialog.drawDialogBox();
                                            yield return
                                                (Dialog.StartCoroutine("drawText",
                                                                       "and received " + receivedItem + " in return."));

                                            while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                                            {
                                                yield return(null);
                                            }
                                        }
                                    }
                                }
                                else if (chosenIndex == 1)
                                {
                                    //Take
                                    Dialog.undrawChoiceBox();
                                    string receivedItem = selectedPokemon.swapHeldItem("");
                                    SaveData.currentSave.Bag.addItem(receivedItem, 1);

                                    updateParty();
                                    updateFrames();

                                    Dialog.drawDialogBox();
                                    yield return
                                        (StartCoroutine(
                                             Dialog.drawText("Took " + receivedItem + " from " +
                                                             selectedPokemon.GetName() + ".")));

                                    while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                                    {
                                        yield return(null);
                                    }
                                }
                            }
                            else
                            {
                                yield return
                                    (StartCoroutine(
                                         Dialog.drawText(selectedPokemon.GetName() + " isn't holding anything.")));

                                choices = new string[]
                                {
                                    "Give", "Cancel"
                                };
                                chosenIndex = -1;
                                Dialog.drawChoiceBox(choices);
                                yield return(new WaitForSeconds(0.2f));

                                yield return(StartCoroutine(Dialog.choiceNavigate(choices)));

                                chosenIndex = Dialog.chosenIndex;

                                if (chosenIndex == 1)
                                {
                                    //Give
                                    SfxHandler.Play(selectClip);
                                    //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f));
                                    yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f)));

                                    PKUScene.main.Bag.gameObject.SetActive(true);
                                    StartCoroutine(PKUScene.main.Bag.control(false, true));
                                    while (PKUScene.main.Bag.gameObject.activeSelf)
                                    {
                                        yield return(null);
                                    }

                                    string chosenItem = PKUScene.main.Bag.chosenItem;

                                    Dialog.undrawChoiceBox();
                                    Dialog.drawDialogBox();
                                    if (string.IsNullOrEmpty(chosenItem))
                                    {
                                        Dialog.drawTextInstant("Choose a Pokémon.");
                                    }
                                    //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f));
                                    yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f)));

                                    if (!string.IsNullOrEmpty(chosenItem))
                                    {
                                        selectedPokemon.swapHeldItem(chosenItem);
                                        SaveData.currentSave.Bag.removeItem(chosenItem, 1);

                                        updateParty();
                                        updateFrames();

                                        Dialog.drawDialogBox();
                                        yield return
                                            (Dialog.StartCoroutine("drawText",
                                                                   "Gave " + chosenItem + " to " + selectedPokemon.GetName() + "."));

                                        while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                                        {
                                            yield return(null);
                                        }
                                    }
                                }
                            }


                            chosenIndex = 0;
                            yield return(new WaitForSeconds(0.2f));
                        }
                    }
                    if (!switching)
                    {
                        Dialog.undrawChoiceBox();
                        Dialog.drawDialogBox();
                        Dialog.drawTextInstant("Choose a Pokémon.");
                    }
                }
            }
            else if (Input.GetButton("Back"))
            {
                if (switching)
                {
                    switching    = false;
                    swapPosition = -1;
                    updateFrames();
                    Dialog.undrawChoiceBox();
                    Dialog.drawDialogBox();
                    Dialog.drawTextInstant("Choose a Pokémon.");
                    yield return(new WaitForSeconds(0.2f));
                }
                else
                {
                    currentPosition = 6;
                    updateFrames();
                    SfxHandler.Play(selectClip);
                    running = false;
                }
            }
            yield return(null);
        }
        StopCoroutine("animateIcons");
        //yield return new WaitForSeconds(sceneTransition.FadeOut());
        yield return(StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed)));

        GlobalVariables.global.resetFollower();
        this.gameObject.SetActive(false);
    }
    private void updateParty()
    {
        for (int i = 0; i < 6; i++)
        {
            OwnedPokemon selectedPokemon = SaveData.currentSave.PC.boxes[0][i];
            if (selectedPokemon == null)
            {
                slot[i].gameObject.SetActive(false);
            }
            else
            {
                slot[i].gameObject.SetActive(true);
                selectBall[i].texture     = selectBallClosed;
                icon[i].texture           = selectedPokemon.GetIcons();
                pokemonName[i].text       = selectedPokemon.GetName();
                pokemonNameShadow[i].text = pokemonName[i].text;
                if (selectedPokemon.Gender == PokemonGender.FEMALE)
                {
                    gender[i].text  = "♀";
                    gender[i].color = new Color(1, 0.2f, 0.2f, 1);
                }
                else if (selectedPokemon.Gender == PokemonGender.MALE)
                {
                    gender[i].text  = "♂";
                    gender[i].color = new Color(0.2f, 0.4f, 1, 1);
                }
                else
                {
                    gender[i].text = null;
                }
                genderShadow[i].text = gender[i].text;
                HPBar[i].pixelInset  = new Rect(HPBar[i].pixelInset.x, HPBar[i].pixelInset.y,
                                                Mathf.FloorToInt(48f * ((float)selectedPokemon.GetCurrentStatValue(PokemonStatType.HP) / (float)selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP))),
                                                HPBar[i].pixelInset.height);

                if ((float)selectedPokemon.GetCurrentStatValue(PokemonStatType.HP) < ((float)selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP) / 4f))
                {
                    HPBar[i].color = new Color(1, 0.125f, 0, 1);
                }
                else if ((float)selectedPokemon.GetCurrentStatValue(PokemonStatType.HP) < ((float)selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP) / 2f))
                {
                    HPBar[i].color = new Color(1, 0.75f, 0, 1);
                }
                else
                {
                    HPBar[i].color = new Color(0.125f, 1, 0.065f, 1);
                }

                level[i].text           = "" + selectedPokemon.CurrentLevel;
                levelShadow[i].text     = level[i].text;
                currentHP[i].text       = "" + selectedPokemon.GetCurrentStatValue(PokemonStatType.HP);
                currentHPShadow[i].text = currentHP[i].text;
                maxHp[i].text           = "" + selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP);
                maxHPShadow[i].text     = maxHp[i].text;
                if (selectedPokemon.CurrentStatus != PokemonStatus.NONE)
                {
                    status[i].texture =
                        Resources.Load <Texture>("PCSprites/status" + selectedPokemon.CurrentStatus.ToString());
                }
                else
                {
                    status[i].texture = null;
                }
                if (!string.IsNullOrEmpty(selectedPokemon.getHeldItem()))
                {
                    item[i].enabled = true;
                }
                else
                {
                    item[i].enabled = false;
                }
            }
        }
    }
    public IEnumerator interact()
    {
        if (!Player.strength)
        {
            OwnedPokemon targetPokemon = SaveData.currentSave.PC.getFirstFieldEffectUserInParty("Strength");
            if (targetPokemon != null)
            {
                if (Player.setCheckBusyWith(this.gameObject))
                {
                    Dialog.drawDialogBox();
                    //yield return StartCoroutine blocks the next code from running until coroutine is done.
                    yield return(Dialog.StartCoroutine("drawText", interactText));

                    Dialog.drawChoiceBox();

                    //You CAN NOT get a value from a Coroutine. As a result, the coroutine runs and resets a public int in it's own script.
                    yield return(Dialog.StartCoroutine(Dialog.choiceNavigate())); //it then assigns a value to that int

                    Dialog.undrawChoiceBox();
                    if (Dialog.chosenIndex == 1)
                    {
                        Dialog.drawDialogBox();
                        yield return
                            (Dialog.StartCoroutine("drawText",
                                                   targetPokemon.GetName() + " used " + targetPokemon.getFirstFEInstance("Strength") + "!")
                            );

                        while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                        {
                            yield return(null);
                        }
                        Dialog.undrawDialogBox();

                        //Activate strength
                        Player.activateStrength();

                        yield return(new WaitForSeconds(0.5f));
                    }
                    Dialog.undrawDialogBox();
                }
            }
            else
            {
                if (Player.setCheckBusyWith(this.gameObject))
                {
                    Dialog.drawDialogBox();
                    //yield return StartCoroutine blocks the next code from running until coroutine is done.
                    yield return(Dialog.StartCoroutine("drawText", examineText));

                    while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                    {
                        yield return(null);
                    }
                    Dialog.undrawDialogBox();
                }
            }
        }
        else
        {
            if (Player.setCheckBusyWith(this.gameObject))
            {
                Dialog.drawDialogBox();
                //yield return StartCoroutine blocks the next code from running until coroutine is done.
                yield return(Dialog.StartCoroutine("drawText", examineTextStrengthActive));

                while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                {
                    yield return(null);
                }
                Dialog.undrawDialogBox();
            }
        }
        yield return(new WaitForSeconds(0.2f));

        Player.unsetCheckBusyWith(this.gameObject);
    }
Example #4
0
    public IEnumerator interact()
    {
        OwnedPokemon targetPokemon = SaveData.currentSave.PC.getFirstFieldEffectUserInParty(fieldEffect);

        if (targetPokemon != null)
        {
            if (PlayerMovement.player.setCheckBusyWith(this.gameObject))
            {
                Dialog.drawDialogBox();
                //yield return StartCoroutine blocks the next code from running until coroutine is done.
                yield return(Dialog.StartCoroutine("drawText", interactText));

                /*          //This inactive code is used to print a third line of text.
                 *  while(!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")){	//these 3 lines stop the next bit from running until space is pressed.
                 *      yield return null;
                 *  }
                 *  Dialog.StartCoroutine("scrollText");
                 *  yield return Dialog.StartCoroutine("drawText", "\\That'd be neat.");
                 */
                Dialog.drawChoiceBox();

                //You CAN NOT get a value from a Coroutine. As a result, the coroutine runs and resets a public int in it's own script.
                yield return(Dialog.StartCoroutine(Dialog.choiceNavigate())); //it then assigns a value to that int

                Dialog.undrawChoiceBox();
                if (Dialog.chosenIndex == 1)
                {
                    //check that int's value

                    Dialog.drawDialogBox();
                    yield return
                        (Dialog.StartCoroutine("drawText",
                                               targetPokemon.GetName() + " used " + targetPokemon.getFirstFEInstance(fieldEffect) + "!"));

                    while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                    {
                        yield return(null);
                    }
                    Dialog.undrawDialogBox();

                    yield return(new WaitForSeconds(0.5f));

                    //Run the animation and remove the tree
                    objectLight.enabled = true;
                    if (!breakSound.isPlaying && !breaking)
                    {
                        breakSound.volume = PlayerPrefs.GetFloat("sfxVolume");
                        breakSound.Play();
                    }
                    myAnimator.SetBool("break", true);
                    myAnimator.SetBool("rewind", false);
                    breaking = true;

                    yield return(new WaitForSeconds(1f));
                }
                Dialog.undrawDialogBox();
                yield return(new WaitForSeconds(0.2f));

                PlayerMovement.player.unsetCheckBusyWith(this.gameObject);
            }
        }
        else
        {
            if (PlayerMovement.player.setCheckBusyWith(this.gameObject))
            {
                Dialog.drawDialogBox();
                //yield return StartCoroutine blocks the next code from running until coroutine is done.
                yield return(Dialog.StartCoroutine("drawText", examineText));

                while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                {
                    yield return(null);
                }
                Dialog.undrawDialogBox();
                yield return(new WaitForSeconds(0.2f));

                PlayerMovement.player.unsetCheckBusyWith(this.gameObject);
            }
        }
    }
Example #5
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);
            }
        }
    }
Example #6
0
    private IEnumerator surfCheck()
    {
        OwnedPokemon targetPokemon = SaveData.currentSave.PC.getFirstFieldEffectUserInParty("Surf");

        if (targetPokemon != null)
        {
            if (getForwardVector(direction, false) != Vector3.zero)
            {
                if (setCheckBusyWith(this.gameObject))
                {
                    Dialog.drawDialogBox();
                    yield return
                        (Dialog.StartCoroutine("drawText",
                                               "The water is dyed a deep blue. Would you \nlike to surf on it?"));

                    Dialog.drawChoiceBox();
                    yield return(Dialog.StartCoroutine("choiceNavigate"));

                    Dialog.undrawChoiceBox();
                    int chosenIndex = Dialog.chosenIndex;
                    if (chosenIndex == 1)
                    {
                        Dialog.drawDialogBox();
                        yield return
                            (Dialog.StartCoroutine("drawText",
                                                   targetPokemon.GetName() + " used " + targetPokemon.getFirstFEInstance("Surf") + "!"));

                        while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                        {
                            yield return(null);
                        }
                        surfing = true;
                        updateMount(true, "surf");

                        BgmHandler.main.PlayMain(GlobalVariables.global.surfBGM, GlobalVariables.global.surfBgmLoopStart);

                        //determine the vector for the space in front of the player by checking direction
                        Vector3 spaceInFront = new Vector3(0, 0, 0);
                        if (direction == 0)
                        {
                            spaceInFront = new Vector3(0, 0, 1);
                        }
                        else if (direction == 1)
                        {
                            spaceInFront = new Vector3(1, 0, 0);
                        }
                        else if (direction == 2)
                        {
                            spaceInFront = new Vector3(0, 0, -1);
                        }
                        else if (direction == 3)
                        {
                            spaceInFront = new Vector3(-1, 0, 0);
                        }

                        mount.transform.position = mount.transform.position + spaceInFront;

                        followerScript.StartCoroutine("withdrawToBall");
                        StartCoroutine("stillMount");
                        forceMoveForward();
                        yield return(StartCoroutine("jump"));

                        updateAnimation("surf", walkFPS);
                        speed = surfSpeed;
                    }
                    Dialog.undrawDialogBox();
                    unsetCheckBusyWith(this.gameObject);
                }
            }
        }
        else
        {
            if (setCheckBusyWith(this.gameObject))
            {
                Dialog.drawDialogBox();
                yield return(Dialog.StartCoroutine("drawText", "The water is dyed a deep blue."));

                while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                {
                    yield return(null);
                }
                Dialog.undrawDialogBox();
                unsetCheckBusyWith(this.gameObject);
            }
        }
        yield return(new WaitForSeconds(0.2f));
    }
    private void updateSelection(OwnedPokemon selectedPokemon)
    {
        frame = 0;

        PlayCry(selectedPokemon);

        selectedCaughtBall.sprite = Resources.Load <Sprite>("null");
        selectedCaughtBall.sprite = Resources.Load <Sprite>("PCSprites/summary" + selectedPokemon.MetData.CaughtBall);
        selectedName.text         = selectedPokemon.GetName();
        selectedNameShadow.text   = selectedName.text;
        if (selectedPokemon.Gender == PokemonGender.FEMALE)
        {
            selectedGender.text  = "♀";
            selectedGender.color = new Color(1, 0.2f, 0.2f, 1);
        }
        else if (selectedPokemon.Gender == PokemonGender.MALE)
        {
            selectedGender.text  = "♂";
            selectedGender.color = new Color(0.2f, 0.4f, 1, 1);
        }
        else
        {
            selectedGender.text = null;
        }
        selectedGenderShadow.text = selectedGender.text;
        selectedLevel.text        = "" + selectedPokemon.CurrentLevel;
        selectedLevelShadow.text  = selectedLevel.text;
        selectedSpriteAnimation   = selectedPokemon.GetFrontAnim_();
        if (selectedSpriteAnimation.Length > 0)
        {
            selectedSprite.sprite = selectedSpriteAnimation[0];
        }
        if (string.IsNullOrEmpty(selectedPokemon.getHeldItem()))
        {
            selectedHeldItem.text = "None";
        }
        else
        {
            selectedHeldItem.text = selectedPokemon.getHeldItem();
        }
        selectedHeldItemShadow.text = selectedHeldItem.text;
        if (selectedPokemon.CurrentStatus != PokemonStatus.NONE)
        {
            selectedStatus.sprite = Resources.Load <Sprite>("PCSprites/status" + selectedPokemon.CurrentStatus.ToString());
        }
        else
        {
            selectedStatus.sprite = Resources.Load <Sprite>("null");
        }

        if (selectedPokemon.IsShiny)
        {
            selectedShiny.sprite = Resources.Load <Sprite>("PCSprites/shiny");
        }
        else
        {
            selectedShiny.sprite = Resources.Load <Sprite>("null");
        }

        dexNo.text         = selectedPokemon.Species.GameId;
        dexNoShadow.text   = dexNo.text;
        species.text       = selectedPokemon.Species.Name;
        speciesShadow.text = species.text;

        // ToDo: implement types.
        //string type1string = PokemonDatabase.Instance.GetPokemonSpeciesByGameId(selectedPokemon.getID()).getType1().ToString();
        //string type2string = PokemonDatabase.Instance.GetPokemonSpeciesByGameId(selectedPokemon.getID()).getType2().ToString();
        //type1.sprite = Resources.Load<Sprite>("null");
        //type2.sprite = Resources.Load<Sprite>("null");
        //if (type1string != "NONE")
        //{
        //    type1.sprite = Resources.Load<Sprite>("PCSprites/type" + type1string);
        //    type1.rectTransform.localPosition = new Vector3(71, type1.rectTransform.localPosition.y);
        //}
        //if (type2string != "NONE")
        //{
        //    type2.sprite = Resources.Load<Sprite>("PCSprites/type" + type2string);
        //}
        //else
        //{
        //    //if single type pokemon, center the type icon
        //    type1.rectTransform.localPosition = new Vector3(89, type1.rectTransform.localPosition.y);
        //}

        // ToDo: implement owner.
        //OT.text = selectedPokemon.getOT();
        //OTShadow.text = OT.text;
        //IDNo.text = "" + selectedPokemon.getIDno();
        //IDNoShadow.text = IDNo.text;

        expPoints.text       = "" + selectedPokemon.CurrentExperience;
        expPointsShadow.text = expPoints.text;
        float expCurrentLevel =
            PokemonLevelingRateHelper.GetRequiredExperienceToTargetLevel(selectedPokemon.Species.LevelingRate,
                                                                         selectedPokemon.CurrentLevel);
        float expNextlevel =
            PokemonLevelingRateHelper.GetRequiredExperienceToTargetLevel(selectedPokemon.Species.LevelingRate,
                                                                         selectedPokemon.CurrentLevel + 1);
        float expAlong    = selectedPokemon.CurrentExperience - expCurrentLevel;
        float expDistance = expAlong / (expNextlevel - expCurrentLevel);

        toNextLevel.text               = "" + (expNextlevel - selectedPokemon.CurrentExperience);
        toNextLevelShadow.text         = toNextLevel.text;
        expBar.rectTransform.sizeDelta = new Vector2(Mathf.Floor(expDistance * 64f), expBar.rectTransform.sizeDelta.y);

        string natureFormatted = PokemonNatureHelper.GetNatureName(selectedPokemon.Nature);

        natureFormatted     = natureFormatted.Substring(0, 1) + natureFormatted.Substring(1).ToLowerInvariant();
        nature.text         = "<color=#F22F>" + natureFormatted + "</color> nature.";
        natureShadow.text   = natureFormatted + " nature.";
        metDate.text        = "Met on " + selectedPokemon.MetData.Date;
        metDateShadow.text  = metDate.text;
        metMap.text         = "<color=#F22F>" + selectedPokemon.MetData.Location + "</color>";
        metMapShadow.text   = selectedPokemon.MetData.Location;
        metLevel.text       = "Met at Level " + selectedPokemon.MetData.Level + ".";
        metLevelShadow.text = metLevel.text;

        string[][] characteristics = new string[][]
        {
            new string[]
            {
                "Loves to eat", "Takes plenty of siestas", "Nods off a lot", "Scatters things often", "Likes to relax"
            },
            new string[]
            {
                "Proud of its power", "Likes to thrash about", "A little quick tempered", "Likes to fight",
                "Quick tempered"
            },
            new string[]
            {
                "Sturdy body", "Capable of taking hits", "Highly persistent", "Good endurance", "Good perseverance"
            },
            new string[]
            {
                "Highly curious", "Mischievous", "Thoroughly cunning", "Often lost in thought", "Very finicky"
            },
            new string[]
            {
                "Strong willed", "Somewhat vain", "Strongly defiant", "Hates to lose", "Somewhat stubborn"
            },
            new string[]
            {
                "Likes to run", "Alert to sounds", "Impetuous and silly", "Somewhat of a clown", "Quick to flee"
            }
        };

        var highestIV = selectedPokemon.GetHighestIV();

        characteristic.text       = characteristics[(int)highestIV][selectedPokemon.GetIV(highestIV) % 5] + ".";
        characteristicShadow.text = characteristic.text;

        float currentHP = selectedPokemon.GetCurrentStatValue(PokemonStatType.HP);
        float maxHP     = selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP);

        HP.text       = currentHP + "/" + maxHP;
        HPShadow.text = HP.text;
        HPBar.rectTransform.sizeDelta = new Vector2(selectedPokemon.getPercentHP() * 48f,
                                                    HPBar.rectTransform.sizeDelta.y);

        if (currentHP < (maxHP / 4f))
        {
            HPBar.color = new Color(1, 0.125f, 0, 1);
        }
        else if (currentHP < (maxHP / 2f))
        {
            HPBar.color = new Color(1, 0.75f, 0, 1);
        }
        else
        {
            HPBar.color = new Color(0.125f, 1, 0.065f, 1);
        }

        //float[] natureMod = new float[]
        //{
        //    NatureDatabase.getNature(selectedPokemon.Nature).getATK(),
        //    NatureDatabase.getNature(selectedPokemon.Nature).getDEF(),
        //    NatureDatabase.getNature(selectedPokemon.Nature).getSPA(),
        //    NatureDatabase.getNature(selectedPokemon.Nature).getSPD(),
        //    NatureDatabase.getNature(selectedPokemon.Nature).getSPE()
        //};
        Stats.text =
            selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.Attack) + "\n" +
            selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.Defence) + "\n" +
            selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.SpecialAttack) + "\n" +
            selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.SpecialDefence) + "\n" +
            selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.Speed);
        StatsShadow.text = Stats.text;

        //string[] statsLines = new string[] { "Attack", "Defence", "Sp. Atk", "Sp. Def", "Speed" };
        StatsTextShadow.text = "";
        //for (int i = 0; i < 5; i++)
        //{
        //    if (natureMod[i] > 1)
        //    {
        //        StatsTextShadow.text += "<color=#A01010FF>" + statsLines[i] + "</color>\n";
        //    }
        //    else if (natureMod[i] < 1)
        //    {
        //        StatsTextShadow.text += "<color=#0030A2FF>" + statsLines[i] + "</color>\n";
        //    }
        //    else
        //    {
        //        StatsTextShadow.text += statsLines[i] + "\n";
        //    }
        //}


        //abilityName.text = PokemonDatabase.Instance.GetPokemonSpeciesByGameId(selectedPokemon.getID().ToString()).getAbility(selectedPokemon.getAbility());
        abilityNameShadow.text = abilityName.text;
        //abilities not yet implemented
        abilityDescription.text       = "";
        abilityDescriptionShadow.text = abilityDescription.text;

        updateSelectionMoveset(selectedPokemon);
    }