예제 #1
0
        private void SetUpPositionQuery(int index, bool left, bool center, bool right)
        {
            SpritedBattlePokemonParty party = _battleParty.Party;
            PBEBattlePokemon          bPkmn = party.BattleParty[index];
            SpritedBattlePokemon      sPkmn = party[bPkmn];
            PartyPokemon pkmn = sPkmn.PartyPkmn;

            _message = string.Format("Send {0} where?", pkmn.Nickname);
            CloseChoices();

            void BackCommand()
            {
                CloseChoices();
                BringUpPkmnActions(index);
            }

            _textChoices = new TextGUIChoices(0, 0, backCommand: BackCommand, font: Font.Default, fontColors: Font.DefaultDarkGray_I, selectedColors: Font.DefaultYellow_O);
            if (left)
            {
                _textChoices.Add(new TextGUIChoice("Send Left", () => SelectForBattleReplacement(bPkmn, PBEFieldPosition.Left)));
            }
            if (center)
            {
                _textChoices.Add(new TextGUIChoice("Send Center", () => SelectForBattleReplacement(bPkmn, PBEFieldPosition.Center)));
            }
            if (right)
            {
                _textChoices.Add(new TextGUIChoice("Send Right", () => SelectForBattleReplacement(bPkmn, PBEFieldPosition.Right)));
            }
            _textChoices.Add(new TextGUIChoice("Cancel", BackCommand));
            _textChoices.GetSize(out int width, out int height);
            _textChoicesWindow = new Window(0.6f, 0.3f, width, height, RenderUtils.Color(255, 255, 255, 255));
            RenderChoicesOntoWindow();
            Game.Instance.SetCallback(CB_Choices);
        }
예제 #2
0
 private void CloseChoices()
 {
     _textChoicesWindow.Close();
     _textChoicesWindow = null;
     _textChoices.Dispose();
     _textChoices = null;
 }
예제 #3
0
        private void BringUpPkmnActions(int index)
        {
            string nickname;

            _textChoices = new TextGUIChoices(0, 0, backCommand: CloseChoicesThenGoToLogicTick, font: Font.Default, fontColors: Font.DefaultDarkGray_I, selectedColors: Font.DefaultYellow_O);
            switch (_mode)
            {
            case Mode.PkmnMenu:
            {
                PartyPokemon pkmn = _gameParty.Party[index];
                nickname = pkmn.Nickname;
                _textChoices.Add(new TextGUIChoice("Check summary", () => Action_BringUpSummary(index)));
                AddFieldMovesToActions(pkmn, index);
                break;
            }

            case Mode.SelectDaycare:
            {
                PartyPokemon pkmn = _gameParty.Party[index];
                nickname = pkmn.Nickname;
                if (!pkmn.IsEgg)
                {
                    _textChoices.Add(new TextGUIChoice("Select", () => Action_SelectPartyPkmn(index)));
                }
                _textChoices.Add(new TextGUIChoice("Check summary", () => Action_BringUpSummary(index)));
                break;
            }

            case Mode.BattleSwitchIn:
            case Mode.BattleReplace:     // Currently same logic
            {
                SpritedBattlePokemonParty party = _battleParty.Party;
                PBEBattlePokemon          bPkmn = party.BattleParty[index];
                SpritedBattlePokemon      sPkmn = party[bPkmn];
                PartyPokemon pkmn = sPkmn.PartyPkmn;
                nickname = pkmn.Nickname;
                // Cannot switch in if active already or fainted, or in the switch stand by
                if (!pkmn.IsEgg && bPkmn.FieldPosition == PBEFieldPosition.None && bPkmn.HP > 0 && !BattleGUI.Instance.StandBy.Contains(bPkmn))
                {
                    _textChoices.Add(new TextGUIChoice("Switch In", () => Action_SelectPartyPkmn(index)));
                }
                _textChoices.Add(new TextGUIChoice("Check summary", () => Action_BringUpSummary(index)));
                break;
            }

            default: throw new Exception();
            }

            _textChoices.Add(new TextGUIChoice("Cancel", CloseChoicesThenGoToLogicTick));
            _textChoices.GetSize(out int width, out int height);
            _textChoicesWindow = new Window(0.6f, 0.3f, width, height, RenderUtils.Color(255, 255, 255, 255));
            RenderChoicesOntoWindow();
            _message = string.Format("Do what with {0}?", nickname);
            Game.Instance.SetCallback(CB_Choices);
        }
예제 #4
0
 private void ShouldLearnMoveAction(bool value)
 {
     if (value)
     {
         _fadeTransition = new FadeToColorTransition(1_000, 0);
         _state          = State.LearnMove_FadeToSummary;
     }
     else
     {
         _textChoicesWindow.Close();
         _textChoicesWindow = null;
         _textChoices.Dispose();
         _textChoices = null;
         _stringPrinter.Close();
         _stringPrinter = null;
         SetGiveUpLearningMove();
     }
 }
예제 #5
0
        public ActionsGUI(SpritedBattlePokemonParty party, PBEBattlePokemon pkmn)
        {
            _party = party;
            _pkmn  = pkmn;

            _fightChoices = new TextGUIChoices(0.75f, 0.75f, bottomAlign: true,
                                               font: Font.Default, fontColors: Font.DefaultWhite_I, selectedColors: Font.DefaultYellow_O, disabledColors: Font.DefaultDisabled);
            _fightChoices.Add(new TextGUIChoice("Fight", FightChoice));
            bool   enabled = pkmn.CanSwitchOut(); // Cannot switch out or use item if TempLockedMove exists
            Action command = enabled ? PokemonChoice : null;

            _fightChoices.Add(new TextGUIChoice("Pokémon", command, isEnabled: enabled));
            command = enabled ? BagChoice : null;
            _fightChoices.Add(new TextGUIChoice("Bag", command, isEnabled: enabled));
            enabled = pkmn.Trainer.ActiveBattlersOrdered.First() == pkmn && pkmn.Trainer.IsFleeValid() is null; // Only first Pokémon can "select" run
            command = enabled ? RunChoice : null;
            _fightChoices.Add(new TextGUIChoice("Run", command, isEnabled: enabled));
        }
예제 #6
0
 private void CreateMoveChoices()
 {
     if (_moveChoices is null)
     {
         PBEBattleMoveset moves       = _pkmn.Moves;
         PBEMove[]        usableMoves = _pkmn.GetUsableMoves();
         _moveChoices = new TextGUIChoices(0.75f, 0.75f, bottomAlign: true, backCommand: SetCallbacksForAllChoices,
                                           font: Font.Default, fontColors: Font.DefaultWhite_I, selectedColors: Font.DefaultYellow_O, disabledColors: Font.DefaultDisabled);
         for (int i = 0; i < PkmnConstants.NumMoves; i++)
         {
             PBEBattleMoveset.PBEBattleMovesetSlot slot = moves[i];
             PBEMove m       = slot.Move;
             string  text    = PBEDataProvider.Instance.GetMoveName(m).English;
             bool    enabled = Array.IndexOf(usableMoves, m) != -1;
             Action  command = enabled ? () => SelectMoveForTurn(m) : null;
             _moveChoices.Add(new TextGUIChoice(text, command, isEnabled: enabled));
         }
     }
 }
예제 #7
0
 private void ShouldGiveUpMoveAction(bool value)
 {
     _textChoicesWindow.Close();
     _textChoicesWindow = null;
     _textChoices.Dispose();
     _textChoices = null;
     _stringPrinter.Close();
     _stringPrinter = null;
     if (value)
     {
         PBEMove move = _learningMoves.Dequeue(); // Remove from queue
         string  str  = PBELocalizedString.GetMoveName(move).English;
         CreateMessage(string.Format("{0} did not learn {1}.", _pkmn.Nickname, str));
         _state = State.LearnMove_DidNotLearnMsg;
     }
     else
     {
         SetWantsToLearnMove();
     }
 }
예제 #8
0
        private void CB_Evolution()
        {
            switch (_state)
            {
            case State.FadeIn:
            {
                if (_fadeTransition.IsDone)
                {
                    _fadeTransition = null;
                    _stringWindow   = new Window(0, 0.79f, 1, 0.16f, RenderUtils.Color(255, 255, 255, 255));
                    CreateMessage(string.Format("{0} is evolving!", _oldNickname));
                    _state = State.IsEvolvingMsg;
                }
                return;
            }

            case State.IsEvolvingMsg:
            {
                if (ReadMessage())
                {
                    _stringPrinter.Close();
                    _stringPrinter  = null;
                    _fadeTransition = new FadeToColorTransition(1_000, RenderUtils.ColorNoA(200, 200, 200));
                    _state          = State.FadeToWhite;
                }
                return;
            }

            case State.FadeToWhite:
            {
                if (TryCancelEvolution())
                {
                    _fadeTransition = null;
                    CreateMessage(string.Format("{0} stopped evolving!", _oldNickname));
                    _state = State.CancelledMsg;
                    return;
                }
                if (_fadeTransition.IsDone)
                {
                    _fadeTransition = null;
                    if (_evo.Method == EvoMethod.Ninjask_LevelUp)
                    {
                        Evolution.TryCreateShedinja(_pkmn);
                    }
                    _pkmn.Evolve(_evo);
                    LoadPkmnImage();
                    _fadeTransition = new FadeFromColorTransition(1_000, RenderUtils.ColorNoA(200, 200, 200));
                    _state          = State.FadeToEvo;
                }
                return;
            }

            case State.FadeToEvo:
            {
                if (_fadeTransition.IsDone)
                {
                    _fadeTransition = null;
                    SoundControl.PlayCry(_pkmn.Species, _pkmn.Form);
                    CreateMessage(string.Format("{0} evolved into {1}!", _oldNickname, PBELocalizedString.GetSpeciesName(_pkmn.Species).English));
                    _state = State.EvolvedIntoMsg;
                }
                return;
            }

            case State.EvolvedIntoMsg:
            {
                if (ReadMessage())
                {
                    _stringPrinter.Close();
                    _stringPrinter = null;
                    // Check for moves to learn
                    _learningMoves = new Queue <PBEMove>(new LevelUpData(_pkmn.Species, _pkmn.Form).GetNewMoves(_pkmn.Level));
                    CheckForLearnMoves();
                }
                return;
            }

            case State.FadeOut:
            {
                if (_fadeTransition.IsDone)
                {
                    _fadeTransition = null;
                    OverworldGUI.Instance.ReturnToFieldWithFadeInAfterEvolutionCheck();
                }
                return;
            }

            case State.CancelledMsg:
            {
                if (ReadMessage())
                {
                    _stringPrinter.Close();
                    _stringPrinter = null;
                    SetFadeOut();
                }
                return;
            }

            // Learning moves
            case State.LearnMove_WantsToLearnMoveMsg:
            {
                if (ReadMessageEnded())
                {
                    TextGUIChoices.CreateStandardYesNoChoices(ShouldLearnMoveAction, out _textChoices, out _textChoicesWindow);
                    _state = State.LearnMove_WantsToLearnMoveChoice;
                }
                return;
            }

            case State.LearnMove_WantsToLearnMoveChoice:
            case State.LearnMove_GiveUpLearningChoice:
            {
                HandleMultichoice();
                return;
            }

            case State.LearnMove_FadeToSummary:
            {
                if (_fadeTransition.IsDone)
                {
                    _fadeTransition           = null;
                    _stringWindow.IsInvisible = true;
                    _textChoicesWindow.Close();
                    _textChoicesWindow = null;
                    _textChoices.Dispose();
                    _textChoices = null;
                    _stringPrinter.Close();
                    _stringPrinter = null;
                    _ = new SummaryGUI(_pkmn, SummaryGUI.Mode.LearnMove, OnSummaryClosed, learningMove: _learningMoves.Peek());
                }
                return;
            }

            case State.LearnMove_FadeFromSummary:
            {
                if (_fadeTransition.IsDone)
                {
                    // Give up on learning
                    if (_forgetMove == -1 || _forgetMove == PkmnConstants.NumMoves)
                    {
                        SetGiveUpLearningMove();
                    }
                    else
                    {
                        Moveset.MovesetSlot slot    = _pkmn.Moveset[_forgetMove];
                        PBEMove             oldMove = slot.Move;
                        string  oldMoveStr          = PBELocalizedString.GetMoveName(oldMove).English;
                        PBEMove move    = _learningMoves.Dequeue();  // Remove from queue
                        string  moveStr = PBELocalizedString.GetMoveName(move).English;
                        slot.Move = move;
                        PBEMoveData mData = PBEMoveData.Data[move];
                        slot.PP    = PBEDataUtils.CalcMaxPP(mData.PPTier, 0, PkmnConstants.PBESettings);
                        slot.PPUps = 0;
                        CreateMessage(string.Format("{0} forgot {1}\nand learned {2}!", _pkmn.Nickname, oldMoveStr, moveStr));
                        _state = State.LearnMove_ForgotMsg;
                    }
                }
                return;
            }

            case State.LearnMove_GiveUpLearningMsg:
            {
                if (ReadMessageEnded())
                {
                    TextGUIChoices.CreateStandardYesNoChoices(ShouldGiveUpMoveAction, out _textChoices, out _textChoicesWindow);
                    _state = State.LearnMove_GiveUpLearningChoice;
                }
                return;
            }

            case State.LearnMove_DidNotLearnMsg:
            case State.LearnMove_ForgotMsg:
            {
                if (ReadMessage())
                {
                    _stringPrinter.Close();
                    _stringPrinter = null;
                    CheckForLearnMoves();
                }
                return;
            }
            }
        }
 /*private void MultichoiceAction(short value)
  * {
  *  Game.Instance.Save.Vars[Var.SpecialVar_Result] = value;
  *  CloseChoices();
  * }*/
 private void YesNoChoiceCommand()
 {
     TextGUIChoices.CreateStandardYesNoChoices(YesNoAction, out _multichoice, out _multichoiceWindow);
 }