Esempio n. 1
0
        private IEnumerator StartItemMenu(Pokemon selectedPokemon)
        {
            int chosenIndex;

            Dialog.UndrawChoiceBox();
            Dialog.DrawDialogBox();
            if (!string.IsNullOrEmpty(selectedPokemon.getHeldItem()))
            {
                yield return(StartCoroutine(
                                 Dialog.DrawText(selectedPokemon.getName() + " is holding " +
                                                 selectedPokemon.getHeldItem() + ".")));

                var choices = new[]
                {
                    "Swap", "Take", "Cancel"
                };
                const int SWAP_INDEX = 2;
                const int TAKE_INDEX = 1;
                Dialog.DrawChoiceBox(choices);
                yield return(new WaitForSeconds(0.2f));

                yield return(StartCoroutine(Dialog.DrawChoiceBox(choices)));

                chosenIndex = Dialog.chosenIndex;
                switch (chosenIndex)
                {
                case SWAP_INDEX:
                {
                    yield return(StartSwappingItem(selectedPokemon));

                    break;
                }

                case TAKE_INDEX:
                {
                    yield return(StartTakingItem(selectedPokemon));

                    break;
                }
                }
            }
            else
            {
                yield return
                    (StartCoroutine(
                         Dialog.DrawText(selectedPokemon.getName() + " isn't holding anything.")));

                var choices = new[]
                {
                    "Give", "Cancel"
                };
                const int GIVE_INDEX = 1;
                Dialog.DrawChoiceBox(choices);
                yield return(new WaitForSeconds(0.2f));

                yield return(StartCoroutine(Dialog.DrawChoiceBox(choices)));

                chosenIndex = Dialog.chosenIndex;
                if (chosenIndex == GIVE_INDEX)
                {
                    yield return(StartGivingItem(selectedPokemon));
                }
            }
            yield return(new WaitForSeconds(0.2f));
        }