예제 #1
0
 internal PBETeam(PBEBattle battle, byte id, PBETeamShell shell, string trainerName)
 {
     Battle = battle;
     Id     = id;
     Party  = new PBEList <PBEPokemon>(Battle.Settings.MaxPartySize);
     CreateParty(shell, trainerName);
 }
 public SpritedBattlePokemonParty(PBEList <PBEBattlePokemon> party)
 {
     OriginalParty = party;
     SpritedParty  = new SpritedBattlePokemon[party.Count];
     for (int i = 0; i < party.Count; i++)
     {
         SpritedParty[i] = new SpritedBattlePokemon(party[i]);
     }
 }
 public SpritedBattlePokemonParty(PBEList <PBEBattlePokemon> pBattle, Party p, bool backImage, bool useKnownInfo, BattleGUI battleGUI)
 {
     Party        = p;
     BattleParty  = pBattle;
     SpritedParty = new SpritedBattlePokemon[pBattle.Count];
     for (int i = 0; i < pBattle.Count; i++)
     {
         PkmnPosition     wildPos = null;
         PBEBattlePokemon pPkmn   = pBattle[i];
         if (pPkmn.IsWild)
         {
             wildPos = battleGUI.GetStuff(pPkmn, pPkmn.FieldPosition);
         }
         SpritedParty[i] = new SpritedBattlePokemon(pBattle[i], p[i], backImage, useKnownInfo, wildPos);
     }
 }
예제 #4
0
 internal PBETeam(PBEBattle battle, byte id)
 {
     Battle = battle;
     Id     = id;
     Party  = new PBEList <PBEPokemon>(Battle.Settings.MaxPartySize);
 }
예제 #5
0
        public PBEBattle(PBEBattleFormat battleFormat, PBESettings settings, IReadOnlyList <PBETrainerInfo> ti0, IReadOnlyList <PBETrainerInfo> ti1, PBEBattleTerrain battleTerrain = PBEBattleTerrain.Plain, PBEWeather weather = PBEWeather.None)
        {
            if (battleFormat >= PBEBattleFormat.MAX)
            {
                throw new ArgumentOutOfRangeException(nameof(battleFormat));
            }
            if (battleTerrain >= PBEBattleTerrain.MAX)
            {
                throw new ArgumentOutOfRangeException(nameof(battleTerrain));
            }
            if (weather >= PBEWeather.MAX)
            {
                throw new ArgumentOutOfRangeException(nameof(weather));
            }
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (!settings.IsReadOnly)
            {
                throw new ArgumentException("Settings must be read-only.", nameof(settings));
            }
            if (ti0 == null || ti0.Any(t => t == null))
            {
                throw new ArgumentNullException(nameof(ti0));
            }
            if (ti1 == null || ti1.Any(t => t == null))
            {
                throw new ArgumentNullException(nameof(ti1));
            }
            BattleTerrain = battleTerrain;
            BattleFormat  = battleFormat;
            Settings      = settings;
            Weather       = weather;
            Teams         = new PBETeams(this, ti0, ti1, out ReadOnlyCollection <PBETrainer> trainers);
            Trainers      = trainers;

            void QueueUp(PBETeam team, int i, PBEFieldPosition pos)
            {
                PBETrainer t;

                if (team.Trainers.Count == 1)
                {
                    t = team.Trainers[0];
                }
                else
                {
                    t = team.GetTrainer(pos);
                    i = 0;
                }
                PBEList <PBEBattlePokemon> party = t.Party;

                if (i < party.Count)
                {
                    PBEBattlePokemon p = party[i];
                    p.Trainer.SwitchInQueue.Add((p, pos));
                }
            }

            switch (BattleFormat)
            {
            case PBEBattleFormat.Single:
            {
                foreach (PBETeam team in Teams)
                {
                    QueueUp(team, 0, PBEFieldPosition.Center);
                }
                break;
            }

            case PBEBattleFormat.Double:
            {
                foreach (PBETeam team in Teams)
                {
                    QueueUp(team, 0, PBEFieldPosition.Left);
                    QueueUp(team, 1, PBEFieldPosition.Right);
                }
                break;
            }

            case PBEBattleFormat.Triple:
            {
                foreach (PBETeam team in Teams)
                {
                    QueueUp(team, 0, PBEFieldPosition.Left);
                    QueueUp(team, 1, PBEFieldPosition.Center);
                    QueueUp(team, 2, PBEFieldPosition.Right);
                }
                break;
            }

            case PBEBattleFormat.Rotation:
            {
                foreach (PBETeam team in Teams)
                {
                    QueueUp(team, 0, PBEFieldPosition.Center);
                    QueueUp(team, 1, PBEFieldPosition.Left);
                    QueueUp(team, 2, PBEFieldPosition.Right);
                }
                break;
            }

            default: throw new ArgumentOutOfRangeException(nameof(BattleFormat));
            }

            BattleState = PBEBattleState.ReadyToBegin;
            OnStateChanged?.Invoke(this);
        }