示例#1
0
        /// <summary>
        /// Start a battle between two trainers
        /// </summary>
        /// <param name="player">the player (or npc I guess)</param>
        /// <param name="opponent">the opponent</param>
        /// <param name="numberOfPositions">number of places on the field (two is the normal)</param>
        public PokeBattle(Trainer player, Trainer opponent, int numberOfPositions)
        {
            lockObject            = new object();
            waitingForPlayerInput = false;

            //throw an error if given an odd number
            if ((numberOfPositions % 2) != 0)
            {
                throw(new ArgumentException("Number of Positions must be even!"));
            }

            position = new BattlePosition[numberOfPositions];

            //set the first half to the player
            for (int i = 0; i < (numberOfPositions / 2); i++)
            {
                position[i] = new BattlePosition(i, player, this);
            }
            //second half to the opponent
            for (int i = (numberOfPositions / 2); i < numberOfPositions; i++)
            {
                position[i] = new BattlePosition(i, opponent, this);
            }
            BattleStack.initializeStacks(this);
            //speedOrder = GetSpeedOrder();
        }
示例#2
0
        public object lockObject; //for thread synchronisation

        /// <summary>
        /// Start a battle between two trainers
        /// </summary>
        /// <param name="player">the player (or npc I guess)</param>
        /// <param name="opponent">the opponent</param>
        public PokeBattle(Trainer player, Trainer opponent)
        {
            position    = new BattlePosition[2];
            position[0] = new BattlePosition(0, player, this);
            position[1] = new BattlePosition(1, opponent, this);

            lockObject            = new object();
            waitingForPlayerInput = false;

            //send out first pokemon in party
            for (int i = 0; i < 6; i++)
            {
                if (player.currentPokemon[i] != null)
                {
                    if (player.currentPokemon[i].currentHP > 0)
                    {
                        Positions[0].SwitchPokemon(new BattlePokemon(player.currentPokemon[i]));
                        break;
                    }
                }
            }
            for (int i = 0; i < 6; i++)
            {
                if (player.currentPokemon[i] != null)
                {
                    if (player.currentPokemon[i].currentHP > 0)
                    {
                        Positions[1].SwitchPokemon(new BattlePokemon(opponent.currentPokemon[i]));
                        break;
                    }
                }
            }
            BattleStack.initializeStacks(this);
        }
示例#3
0
 private void executeStack()
 {
     BattleStack.insertPositions(Positions);
     while (BattleStack.remainingMoves > 0)
     {
         nextPosition = BattleStack.popPosition();
         if (nextPosition.pokemon.currentHealth > 0)
         {
             useMove(nextPosition);
         }
         BattleStack.checkState();
     }
 }
示例#4
0
 public void createEffect(BattlePosition[] targets, int turnsLeft, String effect)
 {
     BattleStack.insertTriggerable(new BattleEffect(this, targets, effect, turnsLeft));
 }