Ejemplo n.º 1
0
        public void addPokemon(
            int number,
            int numberOfTypes,
            Types types,
            string description,
            int level,
            string name,
            int age,
            Pokemon.Gender gender,
            double weight,
            int height)
        {
            Pokemon pokemon = new Pokemon(number, numberOfTypes, types, description, level, name, age, gender, weight, height);

            PokeDex.Add(pokemon);
        }
Ejemplo n.º 2
0
            string TryParseGender(string str, out Pokemon.Gender gender)
            {
                switch (str)
                {
                case ValMale:
                    gender = Pokemon.Gender.Male;
                    return(null);

                case ValFemale:
                    gender = Pokemon.Gender.Female;
                    return(null);

                case ValNone:
                    gender = Pokemon.Gender.None;
                    return(null);

                default:
                    gender = Pokemon.Gender.None;
                    return(str);
                }
            }
    public IEnumerator control(int typeSpaces, string defaultString, Pokemon.Gender genderDisplay,
                               Sprite[] iconAnimation)
    {
        typeSpaceCount = typeSpaces;
        iconAnim       = iconAnimation;
        if (iconAnimation == null)
        {
            icon.sprite = (iconAnimation.Length < 1) ? null : iconAnim[0];
        }

        selectorIndex = 0;
        pageIndex     = 0;

        if (genderDisplay == Pokemon.Gender.FEMALE)
        {
            genderText.text  = "♀";
            genderText.color = new Color(1, 0.2f, 0.2f, 1);
        }
        else if (genderDisplay == Pokemon.Gender.MALE)
        {
            genderText.text  = "♂";
            genderText.color = new Color(0.2f, 0.4f, 1, 1);
        }
        else
        {
            genderText.text = null;
        }
        genderTextShadow.text = genderText.text;

        for (int i = 0; i < typeSpaceCount; i++)
        {
            if (i < defaultString.Length)
            {
                typeSpaceText[i].text = defaultString.Substring(i, 1);
                typeSpaceIndex        = i + 1;
            }
            else
            {
                typeSpaceText[i].text = "";
            }
            typeSpaceTextShadow[i].text = typeSpaceText[i].text;
        }

        page[0].localPosition = new Vector3(0, -31, 0);
        for (int i = 1; i < 4; i++)
        {
            page[i].localPosition = new Vector3(-300f, -31, 0);
        }

        panelButton[0].enabled = true;
        for (int i = 1; i < 6; i++)
        {
            panelButton[i].enabled = false;
        }

        float buttonDelay = 0.15f;

        StartCoroutine(animateSelector());
        StartCoroutine(animateTypeSpace());
        StartCoroutine(animateIcon());

        StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.defaultSpeed));

        bool running = true;

        while (running)
        {
            if (Input.GetAxisRaw("Horizontal") > 0)
            {
                if (selectorIndex < 5)
                {
                    setSelectorPosition(selectorIndex + 1);
                    yield return(new WaitForSeconds(buttonDelay));
                }
                else if (selectorIndex == 5)
                {
                    setSelectorPosition(selectorIndex - 5);
                    yield return(new WaitForSeconds(buttonDelay));
                }
                else if (((selectorIndex - 6) - (Mathf.Floor((float)(selectorIndex - 6) / 13f) * 13)) % 13 < 12)
                {
                    setSelectorPosition(selectorIndex + 1);
                    yield return(new WaitForSeconds(buttonDelay));
                }
                else if (((selectorIndex - 6) - (Mathf.Floor((float)(selectorIndex - 6) / 13f) * 13)) % 13 == 12)
                {
                    setSelectorPosition(selectorIndex - 12);
                    yield return(new WaitForSeconds(buttonDelay));
                }
            }
            else if (Input.GetAxisRaw("Horizontal") < 0)
            {
                if (selectorIndex <= 5)
                {
                    if (selectorIndex == 0)
                    {
                        setSelectorPosition(selectorIndex + 5);
                        yield return(new WaitForSeconds(buttonDelay));
                    }
                    else if (selectorIndex > 0)
                    {
                        setSelectorPosition(selectorIndex - 1);
                        yield return(new WaitForSeconds(buttonDelay));
                    }
                }
                else if (((selectorIndex - 6) - (Mathf.Floor((float)(selectorIndex - 6) / 13f) * 13)) % 13 > 0)
                {
                    setSelectorPosition(selectorIndex - 1);
                    yield return(new WaitForSeconds(buttonDelay));
                }
                else if (((selectorIndex - 6) - (Mathf.Floor((float)(selectorIndex - 6) / 13f) * 13)) % 13 == 0)
                {
                    setSelectorPosition(selectorIndex + 12);
                    yield return(new WaitForSeconds(buttonDelay));
                }
            }
            if (Input.GetAxisRaw("Vertical") > 0)
            {
                if (pageIndex == 3)
                {
                    setSelectorPosition(3);
                    yield return(new WaitForSeconds(buttonDelay));
                }
                else if (selectorIndex > 5)
                {
                    //row 0 of keys
                    if (selectorIndex < 19)
                    {
                        if (selectorIndex > 16)
                        {
                            setSelectorPosition(5);
                        }
                        else if (selectorIndex > 13)
                        {
                            setSelectorPosition(4);
                        }
                        else if (selectorIndex > 11)
                        {
                            setSelectorPosition(3);
                        }
                        else if (selectorIndex > 9)
                        {
                            setSelectorPosition(2);
                        }
                        else if (selectorIndex > 7)
                        {
                            setSelectorPosition(1);
                        }
                        else
                        {
                            setSelectorPosition(0);
                        }
                        yield return(new WaitForSeconds(buttonDelay));
                    }
                    else
                    {
                        setSelectorPosition(selectorIndex - 13);
                        yield return(new WaitForSeconds(buttonDelay));
                    }
                }
            }
            else if (Input.GetAxisRaw("Vertical") < 0)
            {
                if (pageIndex == 3)
                {
                    setSelectorPosition(6);
                    yield return(new WaitForSeconds(buttonDelay));
                }
                else if (selectorIndex < 6)
                {
                    if (selectorIndex == 5)
                    {
                        setSelectorPosition(17);
                    }
                    else if (selectorIndex == 4)
                    {
                        setSelectorPosition(14);
                    }
                    else if (selectorIndex == 3)
                    {
                        setSelectorPosition(12);
                    }
                    else if (selectorIndex == 2)
                    {
                        setSelectorPosition(10);
                    }
                    else if (selectorIndex == 1)
                    {
                        setSelectorPosition(8);
                    }
                    else
                    {
                        setSelectorPosition(6);
                    }
                    yield return(new WaitForSeconds(buttonDelay));
                }
                else if (selectorIndex < 58)
                {
                    setSelectorPosition(selectorIndex + 13);
                    yield return(new WaitForSeconds(buttonDelay));
                }
            }
            if (Input.GetButtonDown("Start"))
            {
                setSelectorPosition(5);
                yield return(new WaitForSeconds(buttonDelay));
            }
            else if (Input.GetButtonDown("Back") || Input.GetButtonDown("Run"))
            {
                yield return(StartCoroutine(backspace()));
            }
            else if (Input.GetButtonDown("Select"))
            {
                if (selectorIndex == 0)
                {
                    //Page0
                    yield return(StartCoroutine(swapPages(0)));
                }
                else if (selectorIndex == 1)
                {
                    //Page1
                    yield return(StartCoroutine(swapPages(1)));
                }
                else if (selectorIndex == 2)
                {
                    //Page2
                    yield return(StartCoroutine(swapPages(2)));
                }
                else if (selectorIndex == 3)
                {
                    //Page3
                    yield return(StartCoroutine(swapPages(3)));
                }
                else if (selectorIndex == 4)
                {
                    //Back
                    yield return(StartCoroutine(backspace()));
                }
                else if (selectorIndex == 5)
                {
                    //OK
                    panelButton[5].enabled = true;
                    yield return(new WaitForSeconds(0.1f));

                    panelButton[5].enabled = false;
                    compileString();
                    running = false;
                }
                else
                {
                    if (pageIndex == 3)
                    {
                        //Keyboard
                        yield return(StartCoroutine(typeWithKeyboard()));
                    }
                    else
                    {
                        //Keys
                        addCurrentKeyToString();
                    }
                }
            }

            yield return(null);
        }

        //yield return new WaitForSeconds(sceneTransition.FadeOut());
        yield return(StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed)));

        gameObject.SetActive(false);
    }
Ejemplo n.º 4
0
    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(Dialog.drawText(
                                          SaveData.currentSave.playerName + " received TM" +
                                          ItemDatabase.getItem(currentEvent.string0).getTMNo() + ": " + currentEvent.string0 + "!"));
            }
            else
            {
                if (currentEvent.int0 > 1)
                {
                    Dialog.StartCoroutine(Dialog.drawText(
                                              SaveData.currentSave.playerName + " received " + currentEvent.string0 + "s!"));
                }
                else if (firstLetter == "a" || firstLetter == "e" || firstLetter == "i" || firstLetter == "o" ||
                         firstLetter == "u")
                {
                    Dialog.StartCoroutine(Dialog.drawText(
                                              SaveData.currentSave.playerName + " received an " + currentEvent.string0 + "!"));
                }
                else
                {
                    Dialog.StartCoroutine(Dialog.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(Dialog.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(Dialog.drawTextSilent(
                                                       SaveData.currentSave.playerName + " put the " + currentEvent.string0 +
                                                       "s \\away into the bag.")));
                    }
                    else
                    {
                        yield return
                            (Dialog.StartCoroutine(Dialog.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(Dialog.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");

                PokemonData pkd = PokemonDatabase.getPokemon(currentEvent.ints[0]);

                string         pkName   = pkd.getName();
                Pokemon.Gender pkGender = Pokemon.Gender.CALCULATE;

                if (pkd.getMaleRatio() == -1)
                {
                    pkGender = Pokemon.Gender.NONE;
                }
                else if (pkd.getMaleRatio() == 0)
                {
                    pkGender = Pokemon.Gender.FEMALE;
                }
                else if (pkd.getMaleRatio() == 100)
                {
                    pkGender = Pokemon.Gender.MALE;
                }
                else
                {
//if not a set gender
                    if (currentEvent.ints[2] == 0)
                    {
                        pkGender = Pokemon.Gender.MALE;
                    }
                    else if (currentEvent.ints[2] == 1)
                    {
                        pkGender = Pokemon.Gender.FEMALE;
                    }
                }

                Dialog.drawDialogBox();
                yield return
                    (Dialog.StartCoroutine(Dialog.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)));

                        Scene.main.Typing.gameObject.SetActive(true);
                        StartCoroutine(Scene.main.Typing.control(10, "", pkGender,
                                                                 Pokemon.GetIconsFromID_(currentEvent.ints[0], currentEvent.bool0)));
                        while (Scene.main.Typing.gameObject.activeSelf)
                        {
                            yield return(null);
                        }
                        if (Scene.main.Typing.typedString.Length > 0)
                        {
                            nickname = Scene.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];
                }

                string pkNature = (currentEvent.ints[3] == 0)
                        ? NatureDatabase.getRandomNature().getName()
                        : NatureDatabase.getNature(currentEvent.ints[3] - 1).getName();

                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]);


                Pokemon pk = new Pokemon(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)
                    {
                        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
            Scene.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(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(true, trainer, currentEvent.bool0));

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

            break;
        }
    }
    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);
        }
    }
Ejemplo n.º 6
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"));
        }
    }