コード例 #1
0
        public ActionsGUI(BattleGUI parent, SpritedBattlePokemonParty party, SpritedBattlePokemon sPkmn)
        {
            _parent = parent;
            _party  = party;
            _pkmn   = sPkmn;

            _fightChoices = new GUIChoices(0.8f, 0.7f, 0.06f,
                                           font: Font.Default, fontColors: Font.DefaultWhite, selectedColors: Font.DefaultSelected, disabledColors: Font.DefaultDisabled)
            {
                new GUIChoice("Fight", FightChoice)
            };
            PBEBattlePokemon pkmn    = _pkmn.Pkmn;
            bool             enabled = pkmn.CanSwitchOut();
            Action           command = enabled ? PokemonChoice : (Action)null;

            _fightChoices.Add(new GUIChoice("Pokémon", command, isEnabled: enabled));
        }
コード例 #2
0
        private void FightChoice()
        {
            PBEBattlePokemon pkmn = _pkmn.Pkmn;
            // Check if there's a move we must use
            bool auto = false;

            if (pkmn.IsForcedToStruggle())
            {
                pkmn.TurnAction = new PBETurnAction(pkmn, PBEMove.Struggle, PBEBattleUtils.GetPossibleTargets(pkmn, pkmn.GetMoveTargets(PBEMove.Struggle))[0]);
                auto            = true;
            }
            else if (pkmn.TempLockedMove != PBEMove.None)
            {
                pkmn.TurnAction = new PBETurnAction(pkmn, pkmn.TempLockedMove, pkmn.TempLockedTargets);
                auto            = true;
            }
            if (auto)
            {
                _parent.ActionsLoop(false);
                return;
            }

            // Create move choices if it's not already created
            if (_moveChoices is null)
            {
                PBEBattleMoveset moves       = pkmn.Moves;
                PBEMove[]        usableMoves = pkmn.GetUsableMoves();
                _moveChoices = new GUIChoices(0.8f, 0.7f, 0.06f, backCommand: () => _isShowingMoves = false,
                                              font: Font.Default, fontColors: Font.DefaultWhite, selectedColors: Font.DefaultSelected, disabledColors: Font.DefaultDisabled);
                for (int i = 0; i < PBESettings.DefaultNumMoves; i++)
                {
                    PBEBattleMoveset.PBEBattleMovesetSlot slot = moves[i];
                    PBEMove m       = slot.Move;
                    string  text    = PBELocalizedString.GetMoveName(m).English;
                    bool    enabled = Array.IndexOf(usableMoves, m) != -1;
                    Action  command = enabled ? () => SelectMoveForTurn(m) : (Action)null;
                    _moveChoices.Add(new GUIChoice(text, command, isEnabled: enabled));
                }
            }

            // Show moves
            _isShowingMoves = true;
        }