Exemple #1
0
    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
                {
                    Pokemon 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
                            Scene.main.Summary.gameObject.SetActive(true);
                            StartCoroutine(Scene.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 (Scene.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)));

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

                                    string chosenItem = Scene.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)));

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

                                    string chosenItem = Scene.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);
    }
Exemple #2
0
    public IEnumerator interact()
    {
        if (PlayerMovement.player.direction == 0)
        {
            if (PlayerMovement.player.setCheckBusyWith(this.gameObject))
            {
                spriteLight.enabled = true;
                PClight.enabled     = true;
                SfxHandler.Play(onClip);
                yield return(StartCoroutine("onAnim"));

                Dialog.drawDialogBox();
                yield return(Dialog.StartCoroutine("drawTextSilent", SaveData.currentSave.playerName + " turned on the PC!"));

                while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                {
                    yield return(null);
                }
                int accessedPC = -1;
                while (accessedPC != 0)
                {
                    Dialog.drawDialogBox();
                    yield return(Dialog.StartCoroutine("drawText", "Which PC should be accessed?"));

                    Dialog.drawChoiceBox(new string[] { "Someone's", "Switch off" });
                    yield return(Dialog.StartCoroutine("choiceNavigate"));

                    Dialog.undrawChoiceBox();
                    accessedPC = Dialog.chosenIndex;
                    int accessedBox = -1;
                    if (accessedPC != 0)
                    {
                        //if not turning off computer
                        Dialog.drawDialogBox();
                        SfxHandler.Play(openClip);
                        yield return
                            (Dialog.StartCoroutine("drawTextSilent", "The Pokémon Storage System \\was accessed."));

                        while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                        {
                            yield return(null);
                        }
                        while (accessedBox != 0 && accessedPC != 0)
                        {
                            //if not turning off computer
                            string[] choices        = new string[] { "Move", "Log off" };
                            string[] choicesFlavour = new string[]
                            {
                                "You may rearrange Pokémon in and \\between your party and Boxes.",
                                "Log out of the Pokémon Storage \\System."
                            };
                            Dialog.drawChoiceBox(choices);
                            Dialog.drawDialogBox();
                            Dialog.drawTextInstant(choicesFlavour[0]);
                            yield return(new WaitForSeconds(0.2f));

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

                            accessedBox = Dialog.chosenIndex;
                            //SceneTransition sceneTransition = Dialog.transform.GetComponent<SceneTransition>();

                            if (accessedBox == 1)
                            {
                                //access Move
                                SfxHandler.Play(selectClip);
                                StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed));
                                yield return(new WaitForSeconds(ScreenFade.defaultSpeed + 0.4f));

                                //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f) + 0.4f);
                                SfxHandler.Play(openClip);
                                //Set ScenePC to be active so that it appears
                                Scene.main.PC.gameObject.SetActive(true);
                                StartCoroutine(Scene.main.PC.control());
                                //Start an empty loop that will only stop when ScenePC is no longer active (is closed)
                                while (Scene.main.PC.gameObject.activeSelf)
                                {
                                    yield return(null);
                                }
                                yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f)));
                                //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f));
                            }

                            Dialog.undrawChoiceBox();
                        }
                    }
                }
                Dialog.undrawDialogBox();
                spriteLight.enabled = false;
                PClight.enabled     = false;
                SfxHandler.Play(offClip);
                yield return(new WaitForSeconds(0.2f));

                PlayerMovement.player.unsetCheckBusyWith(this.gameObject);
            }
        }
    }
Exemple #3
0
    private IEnumerator interact()
    {
        if (PlayerMovement.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 - PlayerMovement.player.transform.position.x;
            float zDistance = this.transform.position.z - PlayerMovement.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("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
                Scene.main.Battle.gameObject.SetActive(true);
                if (trainer.battleBGM != null)
                {
                    BgmHandler.main.PlayOverlay(trainer.battleBGM, trainer.samplesLoopStart);
                }
                else
                {
                    BgmHandler.main.PlayOverlay(Scene.main.Battle.defaultTrainerBGM,
                                                Scene.main.Battle.defaultTrainerBGMLoopStart);
                }
                Scene.main.Battle.gameObject.SetActive(false);
                yield return(new WaitForSeconds(1.6f));

                Scene.main.Battle.gameObject.SetActive(true);
                StartCoroutine(Scene.main.Battle.control(trainer));

                while (Scene.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 (Scene.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("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("drawText", trainerPostDefeatDialog[i]));

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

            busy = false;
            PlayerMovement.player.unsetCheckBusyWith(this.gameObject);
        }
    }
Exemple #4
0
    private IEnumerator surfCheck()
    {
        Pokemon targetPokemon = SaveData.currentSave.PC.getFirstFEUserInParty("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 IEnumerator openAnimNewGame()
    {
        float scrollSpeed = 0.5f;
        float increment   = 0;

        while (increment < 1)
        {
            if (!newGame)
            {
                increment += (1 / scrollSpeed) * Time.deltaTime;
                if (increment > 1)
                {
                    increment = 1;
                }
                transform.Find("FileData").position = new Vector3(0.5f * increment, transform.Find("FileData").position.y, transform.Find("FileData").position.z);
                transform.Find("Continue").position = new Vector3(-0.5f * increment, transform.Find("FileData").position.y, transform.Find("FileData").position.z);
                transform.Find("NewGame").position  = new Vector3(-0.5f * increment, transform.Find("FileData").position.y, transform.Find("FileData").position.z);
                transform.Find("Settings").position = new Vector3(-0.5f * increment, transform.Find("FileData").position.y, transform.Find("FileData").position.z);
            }
            if (transform.Find("FileData").position == new Vector3(0.5f, transform.Find("").position.y, transform.Find("FileData").position.z) || newGame)
            {
                if (!newGame)
                {
                    BgmHandler.main.PlayMain(newGameMusic, 0, true);
                    yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.2f)));

                    transform.Find("Background").gameObject.SetActive(false);
                    transform.Find("FileData").gameObject.SetActive(false);
                    transform.Find("Continue").gameObject.SetActive(false);
                    transform.Find("NewGame").gameObject.SetActive(false);
                    transform.Find("Settings").gameObject.SetActive(false);
                    yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.2f)));

                    newGame = true;
                }
                GlobalVariables.global.SetRPCLargeImageKey("newgame", "Main Menu");
                GlobalVariables.global.SetRPCState("Starting a new game");
                GlobalVariables.global.UpdatePresence();
                yield return(new WaitForSeconds(1f));

                Dialog.drawDialogBox();
                yield return(Dialog.StartCoroutine("drawText", "Are you a boy?\nOr are you a girl?"));

                Dialog.drawChoiceBox(new string[] { "Boy", "Girl" });
                yield return(new WaitForSeconds(0.2f));

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

                int chosenIndexa = Dialog.chosenIndex;
                if (chosenIndexa == 1)     //boy
                {
                    playerName = "Daniel"; //john
                    gender     = true;
                    Dialog.undrawChoiceBox();
                }
                else if (chosenIndexa == 0) //girl
                {
                    playerName = "Daria";   //jane
                    gender     = false;
                    Dialog.undrawChoiceBox();
                }
                Dialog.drawDialogBox();
                yield return(Dialog.StartCoroutine("drawText", "What is your name?"));

                while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                {
                    yield return(null);
                }
                Dialog.undrawDialogBox();
                yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f)));

                Scene.main.Typing.gameObject.SetActive(true);
                if (gender)
                {
                    playerGender = Pokemon.Gender.MALE;
                    playerSprite = null;
                }
                else
                {
                    playerGender = Pokemon.Gender.FEMALE;
                    playerSprite = null;
                }
                StartCoroutine(Scene.main.Typing.control(7, playerName, playerGender, new Sprite[] { playerSprite }));
                while (Scene.main.Typing.gameObject.activeSelf)
                {
                    yield return(null);
                }
                if (Scene.main.Typing.typedString.Length > 0)
                {
                    playerName = Scene.main.Typing.typedString;
                }
                BgmHandler.main.PlayMain(null, 0, false);
                SaveData.currentSave = new SaveData(SaveLoad.getSavedGamesCount());

                GlobalVariables.global.CreateFileData(playerName, gender);

                GlobalVariables.global.playerPosition  = new Vector3(41, -30, 5);
                GlobalVariables.global.playerDirection = 2;
                GlobalVariables.global.fadeIn          = true;
                SaveData.currentSave.setCVariable("indoors", 1);
                GlobalVariables.global.SetRPCLargeImageKey("player_house", "Alferez Village");
                GlobalVariables.global.SetRPCDetails("At home");
                if (PokemonDatabase.getPokemon(SaveData.currentSave.PC.boxes[0][0].getID()).getName() == SaveData.currentSave.PC.boxes[0][0].getName())
                {
                    GlobalVariables.global.SetRPCState("Follower: " + SaveData.currentSave.PC.boxes[0][0].getName() + " (Level " + SaveData.currentSave.PC.boxes[0][0].getLevel().ToString() + ")");
                }
                else
                {
                    GlobalVariables.global.SetRPCState("Follower: " + SaveData.currentSave.PC.boxes[0][0].getName() + " (" + PokemonDatabase.getPokemon(SaveData.currentSave.PC.boxes[0][0].getID()).getName() + ", Level " + SaveData.currentSave.PC.boxes[0][0].getLevel().ToString() + ")");
                }
                UnityEngine.SceneManagement.SceneManager.LoadScene("overworld");
            }
            yield return(null);
        }
    }
    public IEnumerator interact()
    {
        if (PlayerMovement.player.setCheckBusyWith(this.gameObject))
        {
            for (int i = 0; i < 6; i++)
            {
                pokeBalls[i].enabled = false;
            }

            Dialog.drawDialogBox();
            yield return(StartCoroutine(Dialog.drawText("Hello, and welcome to \nthe Pokémon Center.")));

            while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
            {
                yield return(null);
            }
            Dialog.drawDialogBox();
            yield return(StartCoroutine(Dialog.drawText("We restore your tired Pokémon \nto full health.")));

            while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
            {
                yield return(null);
            }
            Dialog.drawDialogBox();
            yield return(StartCoroutine(Dialog.drawText("Would you like to rest your Pokémon?")));

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

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

            if (chosenIndex == 1)
            {
                Dialog.drawDialogBox();
                yield return(StartCoroutine(Dialog.drawText("Okay, I'll take your Pokémon for \na few seconds.")));

                yield return(new WaitForSeconds(0.1f));

                StartCoroutine(PlayerMovement.player.followerScript.withdrawToBall());
                yield return(new WaitForSeconds(0.5f));

                nurse.setDirection(3);

                yield return(new WaitForSeconds(0.2f));

                //place balls on machine, healing as they get shown
                for (int i = 0; i < 6; i++)
                {
                    if (SaveData.currentSave.PC.boxes[0][i] != null)
                    {
                        SaveData.currentSave.PC.boxes[0][i].healFull();
                        pokeBalls[i].enabled = true;
                        SfxHandler.Play(ballPlaceClip);
                        yield return(new WaitForSeconds(0.45f));
                    }
                }
                yield return(new WaitForSeconds(0.25f));

                BgmHandler.main.PlayMFX(healMFX);
                //animate the balls to glow 4 times
                for (int r = 0; r < 4; r++)
                {
                    StartCoroutine(flashScreen(0.45f));
                    for (int i = 0; i < 5; i++)
                    {
                        for (int i2 = 0; i2 < 6; i2++)
                        {
                            pokeBalls[i2].sprite = ballHealSprites[i];
                        }
                        yield return(new WaitForSeconds(0.09f));
                    }
                }

                //reset the ball sprites
                for (int i = 0; i < 6; i++)
                {
                    pokeBalls[i].sprite = ballHealSprites[0];
                }
                yield return(new WaitForSeconds(1f));

                //remove the balls from the machine
                for (int i = 0; i < 6; i++)
                {
                    pokeBalls[i].enabled = false;
                }

                yield return(new WaitForSeconds(0.2f));

                nurse.setDirection(2);

                Dialog.drawDialogBox();
                yield return(StartCoroutine(Dialog.drawText("Thank you for waiting.")));

                while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                {
                    yield return(null);
                }
                Dialog.drawDialogBox();
                yield return(StartCoroutine(Dialog.drawText("We've restored your Pokémon \nto full health.")));

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

                PlayerMovement.player.followerScript.canMove = true;
            }

            Dialog.drawDialogBox();
            yield return(StartCoroutine(Dialog.drawText("We hope to see you again!")));

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

            Dialog.undrawDialogBox();

            PlayerMovement.player.unsetCheckBusyWith(this.gameObject);
        }
    }
    public IEnumerator control()
    {
        //sceneTransition.FadeIn();
        StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.defaultSpeed));

        running = true;
        loadSettings();
        int[] originalIndexes = new int[]
        {
            selectedOptionIndex[0],
            selectedOptionIndex[1],
            selectedOptionIndex[2],
            selectedOptionIndex[3],
            selectedOptionIndex[4],
            selectedOptionIndex[5],
            selectedOptionIndex[6],
            selectedOptionIndex[7]
        };
        //	float originalMVol = PlayerPrefs.GetFloat("musicVolume");
//		float originalSVol = PlayerPrefs.GetFloat("sfxVolume");
        selectedOption       = 0;
        selectRow.pixelInset = new Rect(51, 144, selectRow.pixelInset.width, selectRow.pixelInset.height);
        drawDialogBox();
        drawTextInstant(selectedOptionText[0]);
        while (running)
        {
            if (Input.GetAxisRaw("Vertical") > 0)
            {
                if (selectedOption > 0)
                {
                    selectedOption -= 1;
                    drawDialogBox();
                    if (selectedOption == 0)
                    {
                        StartCoroutine("drawText", selectedOptionText[selectedOption]);
                    }
                    else
                    {
                        drawTextInstant(selectedOptionText[selectedOption]);
                    }
                    SfxHandler.Play(selectClip);
                    yield return(StartCoroutine("moveSelection", 1));
                }
            }
            else if (Input.GetAxisRaw("Vertical") < 0)
            {
                if (selectedOption < 7)
                {
                    selectedOption += 1;
                    StopCoroutine("drawText");
                    drawDialogBox();
                    drawTextInstant(selectedOptionText[selectedOption]);
                    SfxHandler.Play(selectClip);
                    yield return(StartCoroutine("moveSelection", -1));
                }
            }
            else if (Input.GetAxisRaw("Horizontal") > 0)
            {
                if (selectedOption == 1)
                {
                    if (selectedOptionIndex[selectedOption] < selectedOptionSize[selectedOption] - 1)
                    {
                        selectedOptionIndex[selectedOption] += 1;
                        updateOption();
                        yield return(new WaitForSeconds(0.05f));
                    }
                }
                else if (selectedOption == 2)
                {
                    if (selectedOptionIndex[selectedOption] < selectedOptionSize[selectedOption] - 1)
                    {
                        selectedOptionIndex[selectedOption] += 1;
                        updateOption();
                        SfxHandler.Play(selectClip);
                        yield return(new WaitForSeconds(0.05f));
                    }
                }
                else if (selectedOption == 3)
                {
                    selectedOptionIndex[selectedOption] += 1;
                    SfxHandler.Play(selectClip);
                    if (selectedOptionIndex[selectedOption] > selectedOptionSize[selectedOption] - 1)
                    {
                        selectedOptionIndex[selectedOption] = 0;
                    }
                    updateOption();
                    yield return(new WaitForSeconds(0.2f));
                }
                else
                {
                    if (selectedOptionIndex[selectedOption] < selectedOptionSize[selectedOption] - 1)
                    {
                        selectedOptionIndex[selectedOption] += 1;
                        SfxHandler.Play(selectClip);
                        updateOption();
                        if (selectedOption == 0)
                        {
                            StopCoroutine("drawText");
                            drawDialogBox();
                            StartCoroutine("drawText", selectedOptionText[selectedOption]);
                        }
                        yield return(new WaitForSeconds(0.2f));
                    }
                }
            }
            else if (Input.GetAxisRaw("Horizontal") < 0)
            {
                if (selectedOption == 1)
                {
                    if (selectedOptionIndex[selectedOption] > 0)
                    {
                        selectedOptionIndex[selectedOption] -= 1;
                        updateOption();
                        yield return(new WaitForSeconds(0.05f));
                    }
                }
                else if (selectedOption == 2)
                {
                    if (selectedOptionIndex[selectedOption] > 0)
                    {
                        selectedOptionIndex[selectedOption] -= 1;
                        updateOption();
                        SfxHandler.Play(selectClip);
                        yield return(new WaitForSeconds(0.05f));
                    }
                }
                else if (selectedOption == 3)
                {
                    selectedOptionIndex[selectedOption] -= 1;
                    SfxHandler.Play(selectClip);
                    if (selectedOptionIndex[selectedOption] < 0)
                    {
                        selectedOptionIndex[selectedOption] = selectedOptionSize[selectedOption] - 1;
                    }
                    updateOption();
                    yield return(new WaitForSeconds(0.2f));
                }
                else
                {
                    if (selectedOptionIndex[selectedOption] > 0)
                    {
                        selectedOptionIndex[selectedOption] -= 1;
                        SfxHandler.Play(selectClip);
                        updateOption();
                        if (selectedOption == 0)
                        {
                            StopCoroutine("drawText");
                            drawDialogBox();
                            StartCoroutine("drawText", selectedOptionText[selectedOption]);
                        }
                        yield return(new WaitForSeconds(0.2f));
                    }
                }
            }
            else if (Input.GetButton("Back"))
            {
                Dialog.drawDialogBox();
                yield return
                    (Dialog.StartCoroutine("drawText", "Would you like to save the currently \\selected settings?"));

                Dialog.drawChoiceBoxNo();
                yield return(new WaitForSeconds(0.2f));

                yield return(StartCoroutine(Dialog.choiceNavigateNo()));

                int chosenIndex = Dialog.chosenIndex;
                if (chosenIndex == 1)
                {
                    saveSettings();
                }
                else
                {
                    //set music and sfx volume back
                    //	PlayerPrefs.SetFloat("musicVolume",originalMVol);
                    //	PlayerPrefs.SetFloat("sfxVolume",originalSVol);
                    //	PlayerPrefs.Save();
                    selectedOptionIndex = originalIndexes;
                    saveSettings();
                    GlobalVariables.global.updateResolution();
                }
                Dialog.undrawDialogBox();
                Dialog.undrawChoiceBox();
                //yield return new WaitForSeconds(sceneTransition.FadeOut());
                yield return(StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed)));

                running = false;
            }
            yield return(null);
        }
        this.gameObject.SetActive(false);
    }
Exemple #8
0
    private IEnumerator gotoGender()
    {
        Dialog.drawDialogBox();
        yield return(Dialog.StartCoroutine("drawText", "Are you a boy?\nOr are you a girl?"));

        while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
        {
            yield return(null);
        }
        yield return(Dialog.StartCoroutine("scrollText", 0.2f));

        yield return(Dialog.StartCoroutine("drawTextSilent", "Won't you please tell me?"));

        Dialog.drawChoiceBox(new string[] { "Boy", "Girl" });
        yield return(new WaitForSeconds(0.2f));

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

        int chosenIndexa = Dialog.chosenIndex;

        if (chosenIndexa == 1)         //boy
        {
            playerName = "Ethan";      //john
            gender     = true;
            Dialog.undrawChoiceBox();
        }
        else if (chosenIndexa == 0)          //girl
        {
            playerName = "Lyra";             //jane
            gender     = false;
            Dialog.undrawChoiceBox();
        }
        if (gender)
        {
            Dialog.drawDialogBox();
            yield return(Dialog.StartCoroutine("drawText", "So, you're a boy then?"));

            Dialog.drawChoiceBox(new string[] { "Yes", "No" });
            yield return(new WaitForSeconds(0.2f));

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

            int chosenIndexb = Dialog.chosenIndex;
            if (chosenIndexb == 1)             //yes
            {
                Dialog.undrawChoiceBox();
            }
            else if (chosenIndexb == 0)                //no
            {
                Dialog.undrawChoiceBox();
                yield return(StartCoroutine("gotoGender"));
            }
        }
        else
        {
            Dialog.drawDialogBox();
            yield return(Dialog.StartCoroutine("drawText", "So, you're a girl then?"));

            Dialog.drawChoiceBox(new string[] { "Yes", "No" });
            yield return(new WaitForSeconds(0.2f));

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

            int chosenIndexc = Dialog.chosenIndex;
            if (chosenIndexc == 1)             //yes
            {
                Dialog.undrawChoiceBox();
            }
            else if (chosenIndexc == 0)                //no
            {
                Dialog.undrawChoiceBox();
                yield return(StartCoroutine("gotoGender"));
            }
        }

        Dialog.drawDialogBox();
        yield return(Dialog.StartCoroutine("drawText", "Please tell me your name."));

        while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
        {
            yield return(null);
        }
        Dialog.undrawDialogBox();
        yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f)));

        Scene.main.Typing.gameObject.SetActive(true);
        if (gender)
        {
            playerGender = Pokemon.Gender.MALE;
            playerSprite = null;
        }
        else
        {
            playerGender = Pokemon.Gender.FEMALE;
            playerSprite = null;
        }
        StartCoroutine(Scene.main.Typing.control(7, playerName, playerGender, new Sprite[] { playerSprite }));
        while (Scene.main.Typing.gameObject.activeSelf)
        {
            yield return(null);
        }
        if (Scene.main.Typing.typedString.Length > 0)
        {
            playerName = Scene.main.Typing.typedString;
        }
        yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f)));

        Dialog.drawDialogBox();
        yield return(Dialog.StartCoroutine("drawText", "Your name is " + playerName + "?"));

        Dialog.drawChoiceBox(new string[] { "Yes", "No" });
        yield return(new WaitForSeconds(0.2f));

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

        int chosenIndexd = Dialog.chosenIndex;

        if (chosenIndexd == 1)         //yes
        {
            Dialog.undrawChoiceBox();
        }
        else if (chosenIndexd == 0)            //no
        {
            Dialog.undrawChoiceBox();
            yield return(StartCoroutine("gotoGender"));
        }
    }
    public IEnumerator control()
    {
        selectedIcon = 0;
        unhideIcons();
        StartCoroutine("updateIcon", selectedIcon);
        SfxHandler.Play(openClip);
        yield return(StartCoroutine("openAnim"));

        running = true;
        while (running)
        {
            if (selectedIcon == 0)
            {
                if (Input.GetAxisRaw("Vertical") > 0)
                {
                    selectedIcon = 2;
                    StartCoroutine("updateIcon", selectedIcon);
                    SfxHandler.Play(selectClip);
                }
                else if (Input.GetAxisRaw("Horizontal") < 0)
                {
                    selectedIcon = 1;
                    StartCoroutine("updateIcon", selectedIcon);
                    SfxHandler.Play(selectClip);
                }
                else if (Input.GetAxisRaw("Vertical") < 0)
                {
                    selectedIcon = 5;
                    StartCoroutine("updateIcon", selectedIcon);
                    SfxHandler.Play(selectClip);
                }
                else if (Input.GetAxisRaw("Horizontal") > 0)
                {
                    selectedIcon = 3;
                    StartCoroutine("updateIcon", selectedIcon);
                    SfxHandler.Play(selectClip);
                }
            }
            else
            {
                if (Input.GetAxisRaw("Vertical") > 0)
                {
                    if (selectedIcon > 3)
                    {
                        selectedIcon -= 3;
                        StartCoroutine("updateIcon", selectedIcon);
                        SfxHandler.Play(selectClip);
                        yield return(new WaitForSeconds(0.2f));
                    }
                }
                else if (Input.GetAxisRaw("Horizontal") > 0)
                {
                    if (selectedIcon != 3 && selectedIcon != 6)
                    {
                        selectedIcon += 1;
                        StartCoroutine("updateIcon", selectedIcon);
                        SfxHandler.Play(selectClip);
                        yield return(new WaitForSeconds(0.2f));
                    }
                }
                else if (Input.GetAxisRaw("Vertical") < 0)
                {
                    if (selectedIcon < 4)
                    {
                        selectedIcon += 3;
                        StartCoroutine("updateIcon", selectedIcon);
                        SfxHandler.Play(selectClip);
                        yield return(new WaitForSeconds(0.2f));
                    }
                }
                else if (Input.GetAxisRaw("Horizontal") < 0)
                {
                    if (selectedIcon != 1 && selectedIcon != 4)
                    {
                        selectedIcon -= 1;
                        StartCoroutine("updateIcon", selectedIcon);
                        SfxHandler.Play(selectClip);
                        yield return(new WaitForSeconds(0.2f));
                    }
                }
                else if (Input.GetButton("Select"))
                {
                    if (selectedIcon == 1)
                    {
                        //Pokedex
                        Debug.Log("Pokédex not yet implemented");
                        yield return(new WaitForSeconds(0.2f));
                    }
                    else if (selectedIcon == 2)
                    {
                        //Party
                        SfxHandler.Play(selectClip);
                        //StartCoroutine(fadeIcons(0.4f));
                        //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f));
                        yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f)));

                        hideIcons();

                        yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Party.gameObject)));

                        unhideIcons();
                        //StartCoroutine(unfadeIcons(0.4f));
                        //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f));
                        yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f)));
                    }
                    else if (selectedIcon == 3)
                    {
                        //Bag
                        SfxHandler.Play(selectClip);
                        //StartCoroutine(fadeIcons(0.4f));
                        //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f));
                        yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f)));

                        hideIcons();

                        yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Bag.gameObject)));

                        unhideIcons();
                        //StartCoroutine(unfadeIcons(0.4f));
                        //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f));
                        yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f)));
                    }
                    else if (selectedIcon == 4)
                    {
                        //TrainerCard
                        SfxHandler.Play(selectClip);
                        //StartCoroutine(fadeIcons(0.4f));
                        //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f));
                        yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f)));

                        hideIcons();

                        yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Trainer.gameObject)));

                        unhideIcons();
                        //StartCoroutine(unfadeIcons(0.4f));
                        //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f));
                        yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f)));
                    }
                    else if (selectedIcon == 5)
                    {
                        //Save
                        saveDataDisplay.gameObject.SetActive(true);
                        saveDataDisplay.texture =
                            Resources.Load <Texture>("Frame/choice" + PlayerPrefs.GetInt("frameStyle"));
                        iconPokedex.hide = true; //hide this icon as it is in the way
                        int badgeTotal = 0;
                        for (int i = 0; i < 12; i++)
                        {
                            if (SaveData.currentSave.gymsBeaten[i])
                            {
                                badgeTotal += 1;
                            }
                        }
                        string playerTime = "" + SaveData.currentSave.playerMinutes;
                        if (playerTime.Length == 1)
                        {
                            playerTime = "0" + playerTime;
                        }
                        playerTime = SaveData.currentSave.playerHours + " : " + playerTime;

                        mapName.text  = PlayerMovement.player.accessedMapSettings.mapName;
                        dataText.text = SaveData.currentSave.playerName + "\n" +
                                        badgeTotal + "\n" +
                                        "0" + "\n" + //pokedex not yet implemented
                                        playerTime;
                        mapNameShadow.text  = mapName.text;
                        dataTextShadow.text = dataText.text;

                        Dialog.drawDialogBox();
                        yield return(StartCoroutine(Dialog.drawText("Would you like to save the game?")));

                        Dialog.drawChoiceBoxNo();
                        yield return(new WaitForSeconds(0.2f));

                        yield return(StartCoroutine(Dialog.choiceNavigateNo()));

                        int chosenIndex = Dialog.chosenIndex;
                        if (chosenIndex == 1)
                        {
                            //update save file
                            Dialog.undrawChoiceBox();
                            Dialog.drawDialogBox();

                            SaveData.currentSave.levelName       = Application.loadedLevelName;
                            SaveData.currentSave.playerPosition  = new SeriV3(PlayerMovement.player.transform.position);
                            SaveData.currentSave.playerDirection = PlayerMovement.player.direction;
                            SaveData.currentSave.mapName         = PlayerMovement.player.accessedMapSettings.mapName;

                            NonResettingHandler.saveDataToGlobal();

                            SaveLoad.Save();

                            yield return
                                (StartCoroutine(Dialog.drawText(SaveData.currentSave.playerName + " saved the game!")));

                            while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                            {
                                yield return(null);
                            }
                        }
                        Dialog.undrawDialogBox();
                        Dialog.undrawChoiceBox();
                        iconPokedex.hide = false;
                        saveDataDisplay.gameObject.SetActive(false);
                        yield return(new WaitForSeconds(0.2f));
                    }
                    else if (selectedIcon == 6)
                    {
                        //Settings
                        SfxHandler.Play(selectClip);
                        //StartCoroutine(fadeIcons(0.4f));
                        //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f));
                        yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f)));

                        hideIcons();

                        yield return(StartCoroutine(runSceneUntilDeactivated(Scene.main.Settings.gameObject)));

                        unhideIcons();
                        //StartCoroutine(unfadeIcons(0.4f));
                        //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f));
                        yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f)));
                    }
                }
            }
            if (Input.GetButton("Start") || Input.GetButton("Back"))
            {
                running = false;
            }

            yield return(null);
        }

        yield return(StartCoroutine("closeAnim"));

        this.gameObject.SetActive(false);
    }
    public IEnumerator interact()
    {
        if (PlayerMovement.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("drawText",
                                      SaveData.currentSave.playerName + " found TM" + ItemDatabase.getItem(item).getTMNo() + ": " + item +
                                      "!");
            }
            else
            {
                if (quantity > 1)
                {
                    Dialog.StartCoroutine("drawText", SaveData.currentSave.playerName + " found " + item + "s!");
                }
                else if (firstLetter == "a" || firstLetter == "e" || firstLetter == "i" || firstLetter == "o" ||
                         firstLetter == "u")
                {
                    Dialog.StartCoroutine("drawText", SaveData.currentSave.playerName + " found an " + item + "!");
                }
                else
                {
                    Dialog.StartCoroutine("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("drawTextSilent",
                                               SaveData.currentSave.playerName + " put the TM" + ItemDatabase.getItem(item).getTMNo() +
                                               " \\away into the bag."));
                }
                else
                {
                    if (quantity > 1)
                    {
                        yield return
                            (Dialog.StartCoroutine("drawTextSilent",
                                                   SaveData.currentSave.playerName + " put the " + item + "s \\away into the bag."));
                    }
                    else
                    {
                        yield return
                            (Dialog.StartCoroutine("drawTextSilent",
                                                   SaveData.currentSave.playerName + " put the " + item + " \\away into the bag."));
                    }
                }
                while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                {
                    yield return(null);
                }
                Dialog.undrawDialogBox();

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

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

                PlayerMovement.player.unsetCheckBusyWith(this.gameObject);
            }
        }
    }
    private IEnumerator runEvent(CustomEventTree[] treesArray, int index)
    {
        CustomEventDetails currentEvent = treesArray[eventTreeIndex].events[index];
        CustomEventDetails nextEvent    = null;

        if (index + 1 < treesArray[eventTreeIndex].events.Length)
        {
            //if not the last event
            nextEvent = treesArray[eventTreeIndex].events[index + 1];
        }

        NPCHandler targetNPC = null;

        CustomEventDetails.CustomEventType ty = currentEvent.eventType;

        Debug.Log("Run event. Type: " + ty.ToString());

        switch (ty)
        {
        case (CustomEventDetails.CustomEventType.Wait):
            yield return(new WaitForSeconds(currentEvent.float0));

            break;

        case (CustomEventDetails.CustomEventType.Walk):
            if (currentEvent.object0.GetComponent <NPCHandler>() != null)
            {
                targetNPC = currentEvent.object0.GetComponent <NPCHandler>();

                int initialDirection = targetNPC.direction;
                targetNPC.direction = (int)currentEvent.dir;
                for (int i = 0; i < currentEvent.int0; i++)
                {
                    targetNPC.direction = (int)currentEvent.dir;
                    Vector3 forwardsVector = targetNPC.getForwardsVector(true);
                    if (currentEvent.bool0)
                    {
                        //if direction locked in
                        targetNPC.direction = initialDirection;
                    }
                    while (forwardsVector == new Vector3(0, 0, 0))
                    {
                        targetNPC.direction = (int)currentEvent.dir;
                        forwardsVector      = targetNPC.getForwardsVector(true);
                        if (currentEvent.bool0)
                        {
                            //if direction locked in
                            targetNPC.direction = initialDirection;
                        }
                        yield return(new WaitForSeconds(0.1f));
                    }

                    targetNPC.setOverrideBusy(true);
                    yield return(StartCoroutine(targetNPC.move(forwardsVector, currentEvent.float0)));

                    targetNPC.setOverrideBusy(false);
                }
                targetNPC.setFrameStill();
            }     //Move the player if set to player
            if (currentEvent.object0 == PlayerMovement.player.gameObject)
            {
                int initialDirection = PlayerMovement.player.direction;

                PlayerMovement.player.speed = (currentEvent.float0 > 0)
                        ? PlayerMovement.player.walkSpeed / currentEvent.float0
                        : PlayerMovement.player.walkSpeed;
                for (int i = 0; i < currentEvent.int0; i++)
                {
                    PlayerMovement.player.updateDirection((int)currentEvent.dir);
                    Vector3 forwardsVector = PlayerMovement.player.getForwardVector();
                    if (currentEvent.bool0)
                    {
                        //if direction locked in
                        PlayerMovement.player.updateDirection(initialDirection);
                    }

                    PlayerMovement.player.setOverrideAnimPause(true);
                    yield return
                        (StartCoroutine(PlayerMovement.player.move(forwardsVector, false, currentEvent.bool0)));

                    PlayerMovement.player.setOverrideAnimPause(false);
                }
                PlayerMovement.player.speed = PlayerMovement.player.walkSpeed;
            }
            break;

        case (CustomEventDetails.CustomEventType.TurnTo):
            int   direction;
            float xDistance;
            float zDistance;
            if (currentEvent.object0.GetComponent <NPCHandler>() != null)
            {
                targetNPC = currentEvent.object0.GetComponent <NPCHandler>();
            }
            if (targetNPC != null)
            {
                if (currentEvent.object1 != null)
                {
                    //calculate target objects's position relative to this objects's and set direction accordingly.
                    xDistance = targetNPC.hitBox.position.x - currentEvent.object1.transform.position.x;
                    zDistance = targetNPC.hitBox.position.z - currentEvent.object1.transform.position.z;
                    if (xDistance >= Mathf.Abs(zDistance))
                    {
                        //Mathf.Abs() converts zDistance to a positive always.
                        direction = 3;
                    }     //this allows for better accuracy when checking orientation.
                    else if (xDistance <= Mathf.Abs(zDistance) * -1)
                    {
                        direction = 1;
                    }
                    else if (zDistance >= Mathf.Abs(xDistance))
                    {
                        direction = 2;
                    }
                    else
                    {
                        direction = 0;
                    }
                    targetNPC.setDirection(direction);
                }
                if (currentEvent.int0 != 0)
                {
                    direction = targetNPC.direction + currentEvent.int0;
                    while (direction > 3)
                    {
                        direction -= 4;
                    }
                    while (direction < 0)
                    {
                        direction += 4;
                    }
                    targetNPC.setDirection(direction);
                }
            }
            break;

        case (CustomEventDetails.CustomEventType.Dialog):
            for (int i = 0; i < currentEvent.strings.Length; i++)
            {
                Dialog.drawDialogBox();
                yield return(StartCoroutine(Dialog.drawText(currentEvent.strings[i])));

                if (i < currentEvent.strings.Length - 1)
                {
                    while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                    {
                        yield return(null);
                    }
                }
            }
            if (nextEvent != null)
            {
                if (nextEvent.eventType != CustomEventDetails.CustomEventType.Choice)
                {
                    while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                    {
                        yield return(null);
                    }
                    if (!EventRequiresDialogBox(nextEvent.eventType))
                    {
                        Dialog.undrawDialogBox();
                    }     // do not undraw the box if the next event needs it
                }
            }
            else
            {
                while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                {
                    yield return(null);
                }
                Dialog.undrawDialogBox();
            }
            break;

        case (CustomEventDetails.CustomEventType.Choice):
            if (currentEvent.strings.Length > 1)
            {
                Dialog.drawChoiceBox(currentEvent.strings);
                yield return(StartCoroutine(Dialog.choiceNavigate(currentEvent.strings)));
            }
            else
            {
                Dialog.drawChoiceBox();
                yield return(StartCoroutine(Dialog.choiceNavigate()));
            }
            int chosenIndex = Dialog.chosenIndex;
            chosenIndex = currentEvent.ints.Length - 1 - chosenIndex;     //flip it to reflect the original input
            Dialog.undrawChoiceBox();
            Dialog.undrawDialogBox();
            if (chosenIndex < currentEvent.ints.Length)
            {
                //only change tree if index is valid
                if (currentEvent.ints[chosenIndex] != eventTreeIndex &&
                    currentEvent.ints[chosenIndex] < treesArray.Length)
                {
                    JumpToTree(currentEvent.ints[chosenIndex]);
                }
            }
            break;

        case CustomEventDetails.CustomEventType.Sound:
            SfxHandler.Play(currentEvent.sound);
            break;

        case CustomEventDetails.CustomEventType.ReceiveItem:
            //Play Good for TM, Average for Item
            AudioClip itemGetMFX = (currentEvent.bool0)
                    ? Resources.Load <AudioClip>("Audio/mfx/GetGood")
                    : Resources.Load <AudioClip>("Audio/mfx/GetDecent");
            BgmHandler.main.PlayMFX(itemGetMFX);

            string firstLetter = currentEvent.string0.Substring(0, 1).ToLowerInvariant();
            Dialog.drawDialogBox();
            if (currentEvent.bool0)
            {
                Dialog.StartCoroutine("drawText",
                                      SaveData.currentSave.playerName + " received TM" +
                                      ItemDatabase.getItem(currentEvent.string0).getTMNo() + ": " + currentEvent.string0 + "!");
            }
            else
            {
                if (currentEvent.int0 > 1)
                {
                    Dialog.StartCoroutine("drawText",
                                          SaveData.currentSave.playerName + " received " + currentEvent.string0 + "s!");
                }
                else if (firstLetter == "a" || firstLetter == "e" || firstLetter == "i" || firstLetter == "o" ||
                         firstLetter == "u")
                {
                    Dialog.StartCoroutine("drawText",
                                          SaveData.currentSave.playerName + " received an " + currentEvent.string0 + "!");
                }
                else
                {
                    Dialog.StartCoroutine("drawText",
                                          SaveData.currentSave.playerName + " received a " + currentEvent.string0 + "!");
                }
            }
            yield return(new WaitForSeconds(itemGetMFX.length));

            bool itemAdd = SaveData.currentSave.Bag.addItem(currentEvent.string0, currentEvent.int0);

            Dialog.drawDialogBox();
            if (itemAdd)
            {
                if (currentEvent.bool0)
                {
                    yield return
                        (Dialog.StartCoroutine("drawTextSilent",
                                               SaveData.currentSave.playerName + " put the TM" +
                                               ItemDatabase.getItem(currentEvent.string0).getTMNo() + " \\away into the bag."));
                }
                else
                {
                    if (currentEvent.int0 > 1)
                    {
                        yield return
                            (Dialog.StartCoroutine("drawTextSilent",
                                                   SaveData.currentSave.playerName + " put the " + currentEvent.string0 +
                                                   "s \\away into the bag."));
                    }
                    else
                    {
                        yield return
                            (Dialog.StartCoroutine("drawTextSilent",
                                                   SaveData.currentSave.playerName + " put the " + currentEvent.string0 +
                                                   " \\away into the bag."));
                    }
                }
                while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
                {
                    yield return(null);
                }
            }
            else
            {
                yield return(Dialog.StartCoroutine("drawTextSilent", "But there was no room..."));

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

        case CustomEventDetails.CustomEventType.ReceivePokemon:
            if (SaveData.currentSave.PC.hasSpace(0))
            {
                //Play Great for Pokemon
                AudioClip pokeGetMFX = Resources.Load <AudioClip>("Audio/mfx/GetGreat");

                var pkmn = GameController.Instance.PokemonDb.GetPokemonSpeciesByGameId(currentEvent.ints[0].ToString());

                string        pkName   = pkmn.Name;
                PokemonGender pkGender = PokemonGender.CALCULATE;

                if (pkmn.MaleRatio < 0)
                {
                    pkGender = PokemonGender.NONE;
                }
                else if (pkmn.MaleRatio == 0)
                {
                    pkGender = PokemonGender.FEMALE;
                }
                else if (pkmn.MaleRatio == 100)
                {
                    pkGender = PokemonGender.MALE;
                }
                else
                {
                    //if not a set gender
                    if (currentEvent.ints[2] == 0)
                    {
                        pkGender = PokemonGender.MALE;
                    }
                    else if (currentEvent.ints[2] == 1)
                    {
                        pkGender = PokemonGender.FEMALE;
                    }
                }

                Dialog.drawDialogBox();
                yield return
                    (Dialog.StartCoroutine("drawText",
                                           SaveData.currentSave.playerName + " received the " + pkName + "!"));

                BgmHandler.main.PlayMFX(pokeGetMFX);
                yield return(new WaitForSeconds(pokeGetMFX.length));

                string nickname = currentEvent.strings[0];
                if (currentEvent.strings[1].Length == 0)
                {
                    //If no OT set, allow nicknaming of Pokemon

                    Dialog.drawDialogBox();
                    yield return
                        (StartCoroutine(
                             Dialog.drawTextSilent("Would you like to give a nickname to \nthe " + pkName +
                                                   " you received?")));

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

                    int nicknameCI = Dialog.chosenIndex;
                    Dialog.undrawDialogBox();
                    Dialog.undrawChoiceBox();

                    if (nicknameCI == 1)
                    {
                        //give nickname
                        //SfxHandler.Play(selectClip);
                        yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f)));

                        PKUScene.main.Typing.gameObject.SetActive(true);
                        StartCoroutine(PKUScene.main.Typing.control(10, "", pkGender,
                                                                    OwnedPokemon.GetIconsFromID_(currentEvent.ints[0].ToString(), currentEvent.bool0)));
                        while (PKUScene.main.Typing.gameObject.activeSelf)
                        {
                            yield return(null);
                        }
                        if (PKUScene.main.Typing.typedString.Length > 0)
                        {
                            nickname = PKUScene.main.Typing.typedString;
                        }

                        yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f)));
                    }
                }
                if (!EventRequiresDialogBox(nextEvent.eventType))
                {
                    Dialog.undrawDialogBox();
                }

                int[] IVs = new int[]
                {
                    Random.Range(0, 32), Random.Range(0, 32), Random.Range(0, 32),
                    Random.Range(0, 32), Random.Range(0, 32), Random.Range(0, 32)
                };
                if (currentEvent.bool1)
                {
                    //if using Custom IVs
                    IVs[0] = currentEvent.ints[5];
                    IVs[1] = currentEvent.ints[6];
                    IVs[2] = currentEvent.ints[7];
                    IVs[3] = currentEvent.ints[8];
                    IVs[4] = currentEvent.ints[9];
                    IVs[5] = currentEvent.ints[10];
                }

                //PokemonNature pkNature = (currentEvent.ints[3] == 0)
                //    ? PokemonNatureHelper.GetRandomNature()
                //    : (PokemonNature)currentEvent.ints[3] - 1;

                //string[] pkMoveset = pkd.GenerateMoveset(currentEvent.ints[1]);
                //for (int i = 0; i < 4; i++)
                //{
                //    if (currentEvent.strings[4 + i].Length > 0)
                //    {
                //        pkMoveset[i] = currentEvent.strings[4 + i];
                //    }
                //}

                //Debug.Log(pkMoveset[0] + ", " + pkMoveset[1] + ", " + pkMoveset[2] + ", " + pkMoveset[3]);


                //OwnedPokemon pk = new OwnedPokemon(currentEvent.ints[0], nickname, pkGender, currentEvent.ints[1],
                //    currentEvent.bool0, currentEvent.strings[2], currentEvent.strings[3],
                //    currentEvent.strings[1], IVs[0], IVs[1], IVs[2], IVs[3], IVs[4], IVs[5], 0, 0, 0, 0, 0, 0,
                //    pkNature, currentEvent.ints[4],
                //    pkMoveset, new int[4]);

                //SaveData.currentSave.PC.addPokemon(pk);
            }
            else
            {
                //jump to new tree
                JumpToTree(currentEvent.int0);
            }
            break;

        case (CustomEventDetails.CustomEventType.SetActive):
            if (currentEvent.bool0)
            {
                currentEvent.object0.SetActive(true);
            }
            else
            {
                if (currentEvent.object0 == this.gameObject)
                {
                    deactivateOnFinish = true;
                }
                else if (currentEvent.object0 != PlayerMovement.player.gameObject)
                {
                    //important to never deactivate the player
                    currentEvent.object0.SetActive(false);
                }
            }
            break;

        case CustomEventDetails.CustomEventType.SetCVariable:
            SaveData.currentSave.setCVariable(currentEvent.string0, currentEvent.float0);
            break;

        case (CustomEventDetails.CustomEventType.LogicCheck):
            bool passedCheck = false;

            CustomEventDetails.Logic lo = currentEvent.logic;

            switch (lo)
            {
            case CustomEventDetails.Logic.CVariableEquals:
                if (currentEvent.float0 == SaveData.currentSave.getCVariable(currentEvent.string0))
                {
                    passedCheck = true;
                }
                break;

            case CustomEventDetails.Logic.CVariableGreaterThan:
                if (SaveData.currentSave.getCVariable(currentEvent.string0) > currentEvent.float0)
                {
                    passedCheck = true;
                }
                break;

            case CustomEventDetails.Logic.CVariableLessThan:
                if (SaveData.currentSave.getCVariable(currentEvent.string0) < currentEvent.float0)
                {
                    passedCheck = true;
                }
                break;

            case CustomEventDetails.Logic.GymBadgeNoOwned:
                if (Mathf.FloorToInt(currentEvent.float0) < SaveData.currentSave.gymsBeaten.Length &&
                    Mathf.FloorToInt(currentEvent.float0) >= 0)
                {
                    //ensure input number is valid
                    if (SaveData.currentSave.gymsBeaten[Mathf.FloorToInt(currentEvent.float0)])
                    {
                        passedCheck = true;
                    }
                }
                break;

            case CustomEventDetails.Logic.GymBadgesEarned:
                int badgeCount = 0;
                for (int bi = 0; bi < SaveData.currentSave.gymsBeaten.Length; bi++)
                {
                    if (SaveData.currentSave.gymsBeaten[bi])
                    {
                        badgeCount += 1;
                    }
                }
                if (badgeCount >= currentEvent.float0)
                {
                    passedCheck = true;
                }
                break;

            case CustomEventDetails.Logic.PokemonIDIsInParty:
                for (int pi = 0; pi < 6; pi++)
                {
                    if (SaveData.currentSave.PC.boxes[0][pi] != null)
                    {
                        // ToDo: Update this script so it uses the right ID.
                        //if (SaveData.currentSave.PC.boxes[0][pi].getID() ==
                        //    Mathf.FloorToInt(currentEvent.float0))
                        //{
                        //    passedCheck = true;
                        //    pi = 6;
                        //}
                    }
                }
                break;

            case CustomEventDetails.Logic.SpaceInParty:
                if (currentEvent.bool0)
                {
                    if (!SaveData.currentSave.PC.hasSpace(0))
                    {
                        passedCheck = true;
                    }
                }
                else
                {
                    if (SaveData.currentSave.PC.hasSpace(0))
                    {
                        passedCheck = true;
                    }
                }
                break;
            }

            if (passedCheck)
            {
                int newTreeIndex = currentEvent.int0;
                if (newTreeIndex != eventTreeIndex &&     //only change tree if index is valid
                    newTreeIndex < treesArray.Length)
                {
                    JumpToTree(newTreeIndex);
                }
            }
            break;

        case CustomEventDetails.CustomEventType.TrainerBattle:

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

            //Automatic LoopStart usage not yet implemented
            PKUScene.main.Battle.gameObject.SetActive(true);

            Trainer trainer = currentEvent.object0.GetComponent <Trainer>();

            if (trainer.battleBGM != null)
            {
                Debug.Log(trainer.battleBGM.name);
                BgmHandler.main.PlayOverlay(trainer.battleBGM, trainer.samplesLoopStart);
            }
            else
            {
                BgmHandler.main.PlayOverlay(PKUScene.main.Battle.defaultTrainerBGM,
                                            PKUScene.main.Battle.defaultTrainerBGMLoopStart);
            }
            PKUScene.main.Battle.gameObject.SetActive(false);
            yield return(new WaitForSeconds(1.6f));

            PKUScene.main.Battle.gameObject.SetActive(true);
            StartCoroutine(PKUScene.main.Battle.control(true, trainer, currentEvent.bool0));

            while (PKUScene.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 (currentEvent.bool0)
            {
                if (PKUScene.main.Battle.victor == 1)
                {
                    int newTreeIndex = currentEvent.int0;
                    if (newTreeIndex != eventTreeIndex &&     //only change tree if index is valid
                        newTreeIndex < treesArray.Length)
                    {
                        JumpToTree(newTreeIndex);
                    }
                }
            }

            break;
        }
    }
Exemple #12
0
    public IEnumerator interact()
    {
        if (PlayerMovement.player.setCheckBusyWith(this.gameObject))
        {
            if (thisNPC != null)
            {
                int direction;
                //calculate player's position relative to this npc's and set direction accordingly.
                float xDistance = thisNPC.transform.position.x - PlayerMovement.player.transform.position.x;
                float zDistance = thisNPC.transform.position.z - PlayerMovement.player.transform.position.z;
                if (xDistance >= Mathf.Abs(zDistance))                 //Mathf.Abs() converts zDistance to a positive always.
                {
                    direction = 3;
                }                                                       //this allows for better accuracy when checking orientation.
                else if (xDistance <= Mathf.Abs(zDistance) * -1)
                {
                    direction = 1;
                }
                else if (zDistance >= Mathf.Abs(xDistance))
                {
                    direction = 2;
                }
                else
                {
                    direction = 0;
                }
                thisNPC.setDirection(direction);
            }

            string[] choices = new string[] {
                "Shop", "Leave"
            };

            Dialog.drawDialogBox();
            yield return(StartCoroutine(Dialog.drawText(interactDialog)));

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

            int chosenIndex = Dialog.chosenIndex;
            Dialog.undrawChoiceBox();
            while (chosenIndex != 0)
            {
                if (chosenIndex == 1)
                {
                    Dialog.undrawDialogBox();
                    yield return(StartCoroutine(PlayerMovement.player.moveCameraTo(new Vector3(7, 0, 0), 0.35f)));

                    Scene.main.Bag.gameObject.SetActive(true);
                    StartCoroutine(Scene.main.Bag.control(itemCatalog));

                    while (Scene.main.Bag.gameObject.activeSelf)
                    {
                        yield return(null);
                    }

                    yield return(StartCoroutine(PlayerMovement.player.moveCameraTo(new Vector3(0, 0, 0), 0.35f)));
                }

                Dialog.drawDialogBox();
                yield return(StartCoroutine(Dialog.drawText(returnDialog)));

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

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

            Dialog.drawDialogBox();
            yield return(StartCoroutine(Dialog.drawText(leaveDialog)));

            while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back"))
            {
                yield return(null);
            }
            Dialog.undrawDialogBox();
        }
        PlayerMovement.player.unsetCheckBusyWith(this.gameObject);
    }
    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);
    }
Exemple #14
0
    public IEnumerator interact()
    {
        Pokemon targetPokemon = SaveData.currentSave.PC.getFirstFEUserInParty(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);
            }
        }
    }