コード例 #1
0
    void HandlePartySelection()
    {
        dialogBox.EnableActionSelector(false);
        if (!pokemonMoveConfirm)
        {
            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                ++CurrentPokemon;
            }
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                --CurrentPokemon;
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                CurrentPokemon += 2;
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                CurrentPokemon -= 2;
            }

            CurrentPokemon = Mathf.Clamp(CurrentPokemon, 0, playerParty.Pokemons.Count - 1);

            partyScreen.UpdatePokemonSelection(CurrentPokemon);

            if (Input.GetKeyDown(KeyCode.Z))
            {
                var selectedMember = playerParty.Pokemons[CurrentPokemon];
                if (selectedMember.HP <= 0)
                {
                    partyScreen.SetMessageText("You can't send out a fainted Pokemon!");
                    return;
                }
                else if (selectedMember == playerUnit.Pokemon)
                {
                    partyScreen.SetMessageText($"{playerUnit.Pokemon.Base.Name} is already in battle!");
                    return;
                }
                else
                {
                    SelectedMember = selectedMember;
                    partyScreen.SetConfirmActive(true);

                    pokemonMoveConfirm = true;
                }
            }
            else if (Input.GetKeyDown(KeyCode.X))
            {
                partyScreen.gameObject.SetActive(false);
                ActionSelection();
            }
        }
        else
        {
            partyScreen.SetMessageText($"Are you sure you want to send {SelectedMember.Base.Name} into batte?");

            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                ++CurrentConfirm;
            }
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                --CurrentConfirm;
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                ++CurrentConfirm;
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                --CurrentConfirm;
            }

            CurrentPokemon = Mathf.Clamp(CurrentPokemon, 0, 1);

            partyScreen.PokemonConfirmBox.UpdateActionSelection(CurrentConfirm);

            if (Input.GetKeyDown(KeyCode.Z))
            {
                if (CurrentConfirm == 0)
                {
                    partyScreen.gameObject.SetActive(false);
                    state = BattleState.Busy;
                    pokemonMoveConfirm = false;
                    StartCoroutine(SwitchPokemon(SelectedMember));
                }
                else
                {
                    partyScreen.SetMessageText("Choose a Pokemon.");
                    partyScreen.SetConfirmActive(false);
                    pokemonMoveConfirm = false;
                }
            }
            else if (Input.GetKeyDown(KeyCode.X))
            {
                partyScreen.SetMessageText("Choose a Pokemon.");
                partyScreen.SetConfirmActive(false);
                pokemonMoveConfirm = false;
            }
        }
    }