public void ActionsLoop(bool begin) { if (begin) { foreach (PBEBattlePokemon pkmn in _trainer.Party) { pkmn.TurnAction = null; } _actions.Clear(); _actions.AddRange(_trainer.ActiveBattlers); StandBy.Clear(); } int i = _actions.FindIndex(p => p.TurnAction == null); if (i == -1) { _actionsGUI.Dispose(); _actionsGUI = null; new Thread(() => PBEBattle.SelectActionsIfValid(_trainer, _actions.Select(p => p.TurnAction).ToArray())) { Name = ThreadName }.Start(); } else { AddMessage($"What will {_actions[i].Nickname} do?"); SpritedBattlePokemonParty party = _spritedParties[_trainer.Id]; _actionsGUI = new ActionsGUI(this, party, party.SpritedParty[i]); } }
private void SinglePlayerBattle_OnStateChanged(PBEBattle battle) { switch (battle.BattleState) { case PBEBattleState.Ended: { // Copy our Pokémon back from battle, update teammates, update wild Pokémon // Could technically only update what we need (like caught mon, roaming mon, and following partners) for (int i = 0; i < SpritedParties.Length; i++) { SpritedBattlePokemonParty p = SpritedParties[i]; p.UpdateToParty(i == Trainer?.Id); } // Update inventory Game.Instance.Save.PlayerInventory.FromPBEInventory(Trainer.Inventory); // Do capture stuff (temporary) if (Battle.BattleResult == PBEBattleResult.WildCapture) { Game.Instance.Save.GameStats[GameStat.PokemonCaptures]++; PBETrainer wildTrainer = Battle.Teams[1].Trainers[0]; SpritedBattlePokemonParty sp = SpritedParties[wildTrainer.Id]; PBEBattlePokemon wildPkmn = wildTrainer.ActiveBattlers.Single(); PartyPokemon pkmn = sp[wildPkmn].PartyPkmn; pkmn.UpdateFromBattle_Caught(wildPkmn); Game.Instance.Save.GivePokemon(pkmn); } // Pokerus Pokerus.TryCreatePokerus(Game.Instance.Save.PlayerParty); Pokerus.TrySpreadPokerus(Game.Instance.Save.PlayerParty); // Fade out (temporarily until capture screen exists) TransitionOut(); break; } case PBEBattleState.ReadyToRunSwitches: { _battleThread = new Thread(battle.RunSwitches) { Name = ThreadName }; _battleThread.Start(); break; } case PBEBattleState.ReadyToRunTurn: { _battleThread = new Thread(battle.RunTurn) { Name = ThreadName }; _battleThread.Start(); break; } } }
public void UpdateDisguisedPID(SpritedBattlePokemonParty sParty) { if (Pkmn.Status2.HasFlag(PBEStatus2.Disguised)) { PBEBattlePokemon p = Pkmn.GetPkmnWouldDisguiseAs(); DisguisedPID = p is null ? PartyPkmn.PID : sParty[p].PartyPkmn.PID; } else { DisguisedPID = PartyPkmn.PID; // Set back to normal } }
public BattleGUI(PBEBattle battle, Action onClosed) { _battle = battle; _trainer = battle.Trainers[0]; _battleBackground = Sprite.LoadOrGet($"GUI.Battle.Background.BG_{battle.BattleTerrain}_{battle.BattleFormat}.png"); _spritedParties = new SpritedBattlePokemonParty[battle.Trainers.Count]; for (int i = 0; i < battle.Trainers.Count; i++) { _spritedParties[i] = new SpritedBattlePokemonParty(battle.Trainers[i].Party); } _transitionCounter = TransitionDuration; _onClosed = onClosed; battle.OnNewEvent += SinglePlayerBattle_OnNewEvent; battle.OnStateChanged += SinglePlayerBattle_OnStateChanged; }
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)); }
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)); }
public BattleGUI(PBEBattle battle, Action onClosed, IReadOnlyList <Party> trainerParties) : this(battle.BattleFormat) // Init field controller { Battle = battle; Trainer = battle.Trainers[0]; _battleBackground = Image.LoadOrGet($"GUI.Battle.Background.BG_{battle.BattleTerrain}_{battle.BattleFormat}.png"); SpritedParties = new SpritedBattlePokemonParty[battle.Trainers.Count]; for (int i = 0; i < battle.Trainers.Count; i++) { PBETrainer trainer = battle.Trainers[i]; SpritedParties[i] = new SpritedBattlePokemonParty(trainer.Party, trainerParties[i], IsBackImage(trainer.Team), ShouldUseKnownInfo(trainer), this); } _onClosed = onClosed; battle.OnNewEvent += SinglePlayerBattle_OnNewEvent; battle.OnStateChanged += SinglePlayerBattle_OnStateChanged; Instance = this; }
public PartyMenuGUI(SpritedBattlePokemonParty party, Action onClosed) { _party = party; _buttons = new GUIButtons <PartyMemberButton> { new PartyMemberButton(0.01f, 0.01f, _party.SpritedParty.Length > 0 ? _party.SpritedParty[0] : null), new PartyMemberButton(0.51f, 0.01f, _party.SpritedParty.Length > 1 ? _party.SpritedParty[1] : null), new PartyMemberButton(0.01f, 0.33f, _party.SpritedParty.Length > 2 ? _party.SpritedParty[2] : null), new PartyMemberButton(0.51f, 0.33f, _party.SpritedParty.Length > 3 ? _party.SpritedParty[3] : null), new PartyMemberButton(0.01f, 0.65f, _party.SpritedParty.Length > 4 ? _party.SpritedParty[4] : null), new PartyMemberButton(0.51f, 0.65f, _party.SpritedParty.Length > 5 ? _party.SpritedParty[5] : null) }; _onClosed = onClosed; void FadeFromTransitionEnded() { _fadeFromTransition = null; } _fadeFromTransition = new FadeFromColorTransition(20, 0, FadeFromTransitionEnded); }
private void UpdateDisguisedPID(PBEBattlePokemon pkmn) { SpritedBattlePokemonParty sp = SpritedParties[pkmn.Trainer.Id]; sp[pkmn].UpdateDisguisedPID(sp); }