コード例 #1
0
ファイル: PlayerMovement.cs プロジェクト: gouldie/ppo-unity
    private IEnumerator surfCheck()
    {
        // todo: check party has surf move

        if (setCheckBusyWith(this.gameObject))
        {
            Dialog.DrawDialogBox();
            yield return(Dialog.StartCoroutine("DrawText", "The water is dyed a deep blue. \nWould you like to surf on it?"));

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

            Dialog.undrawChoiceBox();
            Dialog.UndrawDialogBox();

            int chosenIndex = Dialog.chosenIndex;
            if (chosenIndex == 1)
            {
                surfing = true;
                updateMount(true, "surf");

                // change background music

                Vector2 spaceInFront = new Vector2(0, 0);
                if (direction == 0)
                {
                    spaceInFront = new Vector2(0, 1);
                }
                else if (direction == 1)
                {
                    spaceInFront = new Vector2(1, 0);
                }
                else if (direction == 2)
                {
                    spaceInFront = new Vector2(0, -1);
                }
                else if (direction == 3)
                {
                    spaceInFront = new Vector2(-1, 0);
                }

                mount.transform.position = mount.transform.position + new Vector3(spaceInFront.x, spaceInFront.y, 0);
                StartCoroutine("stillMount");
                yield return(StartCoroutine(move(getForwardVector())));

                updateAnimation("surf", walkFPS);
                speed = surfSpeed;
            }

            unsetCheckBusyWith(this.gameObject);
        }

        yield return(null);
    }
コード例 #2
0
    /// Main control func
    public IEnumerator control(bool isTrainerBattle, Trainer trainer, bool healedOnDefeat)
    {
        // Set this up later
        int[] initialLevels = new int[6];

        trainerBattle = isTrainerBattle;
        Pokemon[] opponentParty = trainer.GetParty();
        string    opponentName  = trainer.GetName();

        // Get battle backgrounds
        // ...

        victor = -1;

        // Reset position variables
        // ...
        setSelectedTask(-1);


        bool running  = true;
        bool runState = true;

        // Set active Pokemon
        setEnemyActivePokemon(opponentParty[0]);
        setPlayerActivePokemon(playerParty[0]);

        setUpPokemonButtons();

        // Set Pokemon sprites
        opponentBase.transform.FindChild("Pokemon").GetComponent <Image>().sprite = enemyActivePokemon.GetFrontSprite();
        playerBase.transform.FindChild("Pokemon").GetComponent <Image>().sprite   = playerActivePokemon.GetBackSprite();

        if (trainerBattle)
        {
        }
        else
        {
            StartCoroutine(BattleScreenFade.main.FadeCutout(1.5f));
            StartCoroutine(slidePokemon(opponentBase, false, new Vector2(87, 16)));
            yield return(StartCoroutine(slidePokemon(playerBase, true, new Vector2(-84, -58))));

            Dialog.DrawDialogBox();
            StartCoroutine(Dialog.DrawTextSilent("A wild " + enemyActivePokemon.getName() + " appeared!"));
            yield return(new WaitForSeconds(1.0f));

            Dialog.UndrawDialogBox();
        }

        setSelectedTask(0);

        while (running)
        {
            runState = true;
            while (runState)
            {
                Debug.Log(taskSelected);
                if (taskSelected == 0)
                {
                    OptionBox.SetActive(true);
                    PokemonSelectionBox.SetActive(false);
                }
                else if (taskSelected == 4)
                {
                    if (trainerBattle)
                    {
                        OptionBox.SetActive(false);
                        Dialog.DrawDialogBox();
                        yield return(StartCoroutine(Dialog.DrawTextSilent("No! There's no running from a trainer battle!")));

                        yield return(new WaitForSeconds(1.0f));

                        Dialog.UndrawDialogBox();
                        OptionBox.SetActive(true);
                        setSelectedTask(0);
                    }
                    else
                    {
                        OptionBox.SetActive(false);
                        Dialog.DrawDialogBox();
                        yield return(StartCoroutine(Dialog.DrawTextSilent("Got away safely!")));

                        yield return(new WaitForSeconds(1.0f));

                        Dialog.UndrawDialogBox();
                        setSelectedTask(-1);
                        runState = false;
                        running  = false;
                    }
                }
                else if (taskSelected == 2)
                {
                    OptionBox.SetActive(false);
                    PokemonSelectionBox.SetActive(true);

                    while (taskSelected == 2 && pokemonSelected < 0)
                    {
                        Debug.Log("waiting..");
                        yield return(new WaitForSeconds(0.2f));
                    }

                    if (pokemonSelected >= 0)
                    {
                        yield return(StartCoroutine(switchPokemonOut(true, false, false)));

                        yield return(StartCoroutine(switchPokemonIn(true, pokemonSelected)));

                        setSelectedTask(0);
                    }
                }

                yield return(null);
            }
        }

//        yield return null;
        this.gameObject.SetActive(false);
    }