コード例 #1
0
        private void OnActionChosen_Use()
        {
            if (CurrentItem.CanBeUsedFromBag())
            {
                if (CurrentItem is GeneralItem generalCurrentItem &&
                    !generalCurrentItem.GetRequireTargetPokemon())
                {
                    // General items that don't require a pokemon target to be used

                    // Items are handled for individual cases as functionalities are too unique to generalise

                    // Switch statement for different possible items that are being used
                    switch (generalCurrentItem.id)
                    {
                    case GeneralItem.repelId:
                    case GeneralItem.superRepelId:
                    case GeneralItem.maxRepelId:
                        OnActionChosen_Use_Repel(generalCurrentItem);
                        break;

                    default:
                        Debug.LogError("Unhandled general no-target-pokemon item id - " + generalCurrentItem.id);
                        break;
                    }

                    PlayerData.singleton.inventory.RemoveItem(CurrentItem, 1);

                    textBoxController.Show();
                    textBoxController.SetTextInstant($"{CurrentItem.itemName} was used");
                    textBoxController.SetHideDelay(1.5F);

                    ChangeToSectionSelection(false);
                }
                else
                {
                    // Default case

                    pokemonSelectionMode = PokemonSelectionMode.Use;
                    ChangeToPokemonSelection();
                }
            }
コード例 #2
0
        public void OnActionChosen(int chosenActionIndex)
        {
            currentActionIndex = chosenActionIndex;

            switch (currentActionIndex)
            {
            case 0:     //Cancel button
                ChangeToSectionSelection(false);
                break;

            case 1:     //Use button
                OnActionChosen_Use();
                break;

            case 2:     //Give button
                pokemonSelectionMode = PokemonSelectionMode.Give;
                ChangeToPokemonSelection();
                break;

            default:
                Debug.LogError("Unhandled currentActionIndex - " + currentActionIndex);
                break;
            }
        }