Exemple #1
0
    public IEnumerator interact()
    {
        if (isLocked)
        {
            if (lockedExamineText.Length > 0)
            {
                if (Player.player.setCheckBusyWith(this.gameObject))
                {
                    Dialog.DrawDialogBox();
                    //yield return StartCoroutine blocks the next code from running until coroutine is done.
                    yield return(Dialog.StartCoroutine("drawText", lockedExamineText));

                    while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                    {
                        //these 3 lines stop the next bit from running until space is pressed.
                        yield return(null);
                    }
                    Dialog.UnDrawDialogBox();
                    yield return(new WaitForSeconds(0.2f));

                    Player.player.unsetCheckBusyWith(this.gameObject);
                }
            }
        }
        else
        {
            if (examineText.Length > 0)
            {
                if (Player.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"))
                    {
                        //these 3 lines stop the next bit from running until space is pressed.
                        yield return(null);
                    }
                    Dialog.UnDrawDialogBox();
                    yield return(new WaitForSeconds(0.2f));

                    Player.player.unsetCheckBusyWith(this.gameObject);
                }
            }
        }
    }
Exemple #2
0
        private IEnumerator ControlPokemonOptions()
        {
            var       selectedPokemon = SaveData.currentSave.PC.boxes[0][currentPosition];
            var       chosenIndex     = -1;
            const int CANCEL_INDEX    = 0;

            while (chosenIndex != CANCEL_INDEX)
            {
                const int ITEM_INDEX    = 1;
                const int SWITCH_INDEX  = 2;
                const int SUMMARY_INDEX = 3;
                SfxHandler.Play(selectClip);
                yield return(PromptPokemonOptions(selectedPokemon));

                chosenIndex = Dialog.chosenIndex;
                switch (chosenIndex)
                {
                case SUMMARY_INDEX:
                    yield return(ControlSummary());

                    chosenIndex = 0;
                    break;

                case SWITCH_INDEX:
                    yield return(StartSwitching(selectedPokemon));

                    chosenIndex = 0;
                    break;

                case ITEM_INDEX:
                {
                    yield return(StartItemMenu(selectedPokemon));

                    chosenIndex = 0;
                    break;
                }
                }
            }
            if (switching)
            {
                yield break;
            }
            Dialog.UndrawChoiceBox();
            Dialog.DrawDialogBox();
            yield return(PromptChoosePokemon());
        }
        public IEnumerator interact()
        {
            if (Player.player.setCheckBusyWith(this.gameObject))
            {
                AudioClip itemGetMFX = (TM)
                ? Resources.Load <AudioClip>("Audio/mfx/GetGood")
                : Resources.Load <AudioClip>("Audio/mfx/GetDecent");
                BgmHandler.main.PlayMFX(itemGetMFX);

                string firstLetter = item.Substring(0, 1).ToLowerInvariant();
                Dialog.DrawDialogBox();
                if (TM)
                {
                    Dialog.StartCoroutine(Dialog.DrawText(
                                              SaveData.currentSave.playerName + " found TM" + ItemDatabase.getItem(item).getTMNo() + ": " + item +
                                              "!"));
                }
                else
                {
                    if (quantity > 1)
                    {
                        Dialog.StartCoroutine(Dialog.DrawText(SaveData.currentSave.playerName + " found " + item + "s!"));
                    }
                    else if (firstLetter == "a" || firstLetter == "e" || firstLetter == "i" || firstLetter == "o" ||
                             firstLetter == "u")
                    {
                        Dialog.StartCoroutine(Dialog.DrawText(SaveData.currentSave.playerName + " found an " + item + "!"));
                    }
                    else
                    {
                        Dialog.StartCoroutine(Dialog.DrawText(SaveData.currentSave.playerName + " found a " + item + "!"));
                    }
                }
                yield return(new WaitForSeconds(itemGetMFX.length));

                bool itemAdd = SaveData.currentSave.Bag.addItem(item, quantity);

                Dialog.DrawDialogBox();
                if (itemAdd)
                {
                    itemSprite.enabled   = false;
                    itemShadow.enabled   = false;
                    transform.position   = new Vector3(transform.position.x, transform.position.y - 1f, transform.position.z);
                    transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);

                    if (TM)
                    {
                        yield return
                            (Dialog.StartCoroutine(Dialog.DrawTextSilent(
                                                       SaveData.currentSave.playerName + " put the TM" + ItemDatabase.getItem(item).getTMNo() +
                                                       " away into the bag.")));
                    }
                    else
                    {
                        if (quantity > 1)
                        {
                            yield return
                                (Dialog.StartCoroutine(Dialog.DrawTextSilent(
                                                           SaveData.currentSave.playerName + " put the " + item + "s away into the bag.")));
                        }
                        else
                        {
                            yield return
                                (Dialog.StartCoroutine(Dialog.DrawTextSilent(
                                                           SaveData.currentSave.playerName + " put the " + item + " away into the bag.")));
                        }
                    }
                    while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                    {
                        yield return(null);
                    }
                    Dialog.UnDrawDialogBox();

                    Player.player.unsetCheckBusyWith(this.gameObject);
                    gameObject.SetActive(false);
                }
                else
                {
                    yield return(Dialog.StartCoroutine(Dialog.DrawTextSilent("But there was no room...")));

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

                    Player.player.unsetCheckBusyWith(this.gameObject);
                }
            }
        }
        private IEnumerator interact()
        {
            if (Player.player.setCheckBusyWith(this.gameObject))
            {
                busy = true;

                //calculate Player's position relative to target object's and set direction accordingly.
                float xDistance = this.transform.position.x - Player.player.transform.position.x;
                float zDistance = this.transform.position.z - Player.player.transform.position.z;
                if (xDistance >= Mathf.Abs(zDistance))
                {
                    //Mathf.Abs() converts zDistance to a positive always.
                    updateDirection(3);
                } //this allows for better accuracy when checking orientation.
                else if (xDistance <= Mathf.Abs(zDistance) * -1)
                {
                    updateDirection(1);
                }
                else if (zDistance >= Mathf.Abs(xDistance))
                {
                    updateDirection(2);
                }
                else
                {
                    updateDirection(0);
                }

                if (!defeated)
                {
                    //Play INTRO BGM
                    BgmHandler.main.PlayOverlay(introBGM, samplesLoopStart);

                    //Display all of the confrontation Dialog.
                    for (int i = 0; i < trainerConfrontDialog.Length; i++)
                    {
                        Dialog.DrawDialogBox();
                        yield return(Dialog.StartCoroutine(Dialog.DrawText(trainerConfrontDialog[i])));

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

                    //custom cutouts not yet implemented
                    StartCoroutine(ScreenFade.main.FadeCutout(false, ScreenFade.slowedSpeed, null));

                    //Automatic LoopStart usage not yet implemented
                    SceneScript.main.Battle.gameObject.SetActive(true);
                    if (trainer.battleBGM != null)
                    {
                        BgmHandler.main.PlayOverlay(trainer.battleBGM, trainer.samplesLoopStart);
                    }
                    else
                    {
                        BgmHandler.main.PlayOverlay(SceneScript.main.Battle.defaultTrainerBGM,
                                                    SceneScript.main.Battle.defaultTrainerBGMLoopStart);
                    }
                    SceneScript.main.Battle.gameObject.SetActive(false);
                    yield return(new WaitForSeconds(1.6f));

                    SceneScript.main.Battle.gameObject.SetActive(true);
                    StartCoroutine(SceneScript.main.Battle.Control(trainer));

                    while (SceneScript.main.Battle.gameObject.activeSelf)
                    {
                        yield return(null);
                    }

                    //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f));
                    yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f)));

                    if (SceneScript.main.Battle.victor == 0)
                    {
                        defeated         = true;
                        recentlyDefeated = true;
                        //Display all of the defeated Dialog. (if any)
                        for (int i = 0; i < trainerDefeatDialog.Length; i++)
                        {
                            Dialog.DrawDialogBox();
                            yield return(Dialog.StartCoroutine(Dialog.DrawText(trainerDefeatDialog[i])));

                            while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                            {
                                yield return(null);
                            }
                            Dialog.UnDrawDialogBox();
                        }
                    }
                }
                else
                {
                    //Display all of the post defeat Dialog.
                    for (int i = 0; i < trainerPostDefeatDialog.Length; i++)
                    {
                        Dialog.DrawDialogBox();
                        yield return(Dialog.StartCoroutine(Dialog.DrawText(trainerPostDefeatDialog[i])));

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

                busy = false;
                Player.player.unsetCheckBusyWith(this.gameObject);
            }
        }