/// <summary>
        /// Adds a player to the list of managed players.
        /// </summary>
        /// <param name="playerIndex">Index of the game pad associated with this player.</param>
        public void AddPlayer(PlayerIndex playerIndex)
        {
            //Create a new player object
            Player newPlayer = new Player(this.gamePointer, playerIndex);

            //Add the new player to our list of players
            playerList.Add(newPlayer);
        }
        private void checkCollision(Player currentPlayer)
        {
            //Check for collisions
            for (int j = 0; j < currentPlayer.shipManager.shipList.Count; j++)
            {
                //Cache current player
                Gryffon _currentShip = currentPlayer.shipManager.shipList[j];
                // When ships can become damaged, uncomment line below
                // if (Collision.PlayerWithPowerup(_currentShip, repairPowerup) && _currentShip.health == (int)Gryffon.HealthStateValues.DAMAGED)
                //if (Collision.PlayerWithPowerup(_currentShip, repairPowerup))
                  //  RepairPowerup.sequence();

                int _playerNumBullets = _currentShip.bulletList.Count;
                for (int i = 0; i < _playerNumBullets; i++)
                {
                    //Cache bullet
                    PlayerBullet _currentBullet = _currentShip.bulletList[i];
                    if (_currentBullet.isActive)
                        for (int k = 0; k < NUM_ENEMIES; k++)
                        {
                            //Cache enemy
                            Pawn _currentPawn = (Pawn)enemySpriteManager.spriteList[k];
                            if (_currentPawn.isAlive && Collision.PlayerBulletWithEnemy(_currentBullet, _currentPawn))
                            {
                                _currentPawn.DecreaseHealth(_currentBullet.damage);
                                _currentBullet.isActive = false;
                                currentPlayer.score += _currentPawn.pointValue;
                                //Pawn is no longer able to take damage
                                _currentPawn.isAlive = false;

                                // Add some charge to the charge bar
                                ChargeBar.addCharge();
                                break;
                            }
                        }
                }
            }
        }
        private void checkCollision(Player currentPlayer)
        {
            //Check for collisions
            for (int j = 0; j < currentPlayer.shipManager.shipList.Count; j++)
            {
                //Cache current player
                Gryffon _currentShip = currentPlayer.shipManager.shipList[j];
                for (int i = 0; i < powerupManager.powerupList.Count; i++)
                {
                    // cache powerup
                    AnimatedSprite _powerup = powerupManager.powerupList[i];
                    if (Collision.PlayerWithPowerup(_currentShip, _powerup))
                        PowerupManager.collisionMade(_powerup);

                    PowerupManager.inputManager(_powerup, ref currentPlayer);
                }

                int _playerNumBullets = _currentShip.bulletList.Count;
                for (int i = 0; i < _playerNumBullets; i++)
                {
                    //Cache bullet
                    PlayerBullet _currentBullet = _currentShip.bulletList[i];
                    if (_currentBullet.isActive)
                        for (int k = 0; k < NUM_ENEMIES; k++)
                        {
                            //Cache enemy
                            Pawn _currentPawn = (Pawn)enemySpriteManager.spriteList[k];
                            if (_currentPawn.isAlive && Collision.PlayerBulletWithEnemy(_currentBullet, _currentPawn))
                            {
                                _currentPawn.DecreaseHealth(_currentBullet.damage);
                                _currentBullet.isActive = false;
                                currentPlayer.score += _currentPawn.pointValue;
                                //Pawn is no longer able to take damage
                                _currentPawn.isAlive = false;

                                // Add some charge to the charge bar
                                ChargeBar.addCharge();
                                break;
                            }
                        }
                }
            }

            //Check for collisions between particles and enemies
            List<ParticleSystem> pSystems = Defines.particleManager.GetCollidableParticleSystems();
            for (int i = 0; i < pSystems.Count; i++)
                for (int k = 0; k < NUM_ENEMIES; k++)
                {
                    //Cache enemy
                    Pawn _currentPawn = (Pawn)enemySpriteManager.spriteList[k];

                    //Collision between enemy and particle system
                    if (Collision.EnemyWithParticleSystem(pSystems[i], _currentPawn))
                    {
                        _currentPawn.DecreaseHealth(pSystems[i].damage);
                        currentPlayer.score += _currentPawn.pointValue;
                        //Pawn is no longer able to take damage
                        _currentPawn.isAlive = false;
                        // Add some charge to the charge bar
                        ChargeBar.addCharge();
                    }

                    //Collision between enemy bullets and particle system
                    for (int b = 0; b < _currentPawn.bullets.Count; b++)
                    {
                        EnemyBullet _curBullet = _currentPawn.bullets[b];
                        if(Collision.EnemyWithParticleSystem(pSystems[i], _curBullet))
                        {
                            _curBullet.isActive = false;
                        }
                    }
                }
        }
 /// <summary>
 /// Used to collect and assign actions to the current powerup
 /// </summary>
 /// <param name="powerup"></param>
 /// <param name="player"></param>
 public static void inputManager(AnimatedSprite powerup, ref Player player)
 {
     // Check if the powerup is of type 'RepairPowerup'
     if (!powerup.isActive && powerup is RepairPowerup)
         RepairPowerup.sequence((RepairPowerup)powerup, ref player);
 }
        public static void sequence(RepairPowerup powerup, ref Player player)
        {
            // Prevent us from restarting the sequence
            if (!enterRepairMode && !repairModeEnabled && !powerup.rechargeModeEnabled)
                enterRepairMode = true;

            currentPlayer = player;
        }
        public void checkInput(GameTime gameTime, Player player)
        {
            float _timeLeft = delay - (float)gameTime.TotalGameTime.TotalSeconds;
            GamePadState _currentAction = GamePad.GetState(player.playerIndex);

            // Display message to enter repair mode

            if (enterRepairMode)
            {
                if (_currentAction.ThumbSticks.Right.X != 0 || _currentAction.ThumbSticks.Right.Y != 0)
                {
                    enterRepairMode = false;
                    repairModeEnabled = true;
                }
                else
                    status = "Hit the right analog stick in any direction to enter repair mode!!";
            }

            // Repair mode entered
            else if (repairModeEnabled)
            {
                if (repairCharge > 0)
                {
                    // Check 'A' button state
                    if (_currentAction.IsButtonDown(Buttons.A) && !buttonHeldDown_A)
                    {
                        buttonHeldDown_A = true;
                        repairCharge--;
                    }
                    else if (_currentAction.IsButtonUp(Buttons.A) && buttonHeldDown_A)
                        buttonHeldDown_A = false;

                    status = "Push the 'A' Button " + repairCharge + " more times!!";
                }
                else
                {
                    repairModeEnabled = false;
                    rechargeModeEnabled = true;

                    // Keep delay value updated for when Repair Mode ends
                    delay = (int)gameTime.TotalGameTime.TotalSeconds + duration;

                    // Show "explosive" recovery!
                    //GameplayScreen.particleManager.AddParticleSystem(ParticleSystem, player.shipManager.formationManager.globalFixedPoint);
                }
            }

            // Repair complete, recharge mode start
            else if (rechargeModeEnabled)
            {
                if (_timeLeft > 0)
                    status = "Time till Next Power Up:  " + _timeLeft.ToString("N2");
                else
                {
                    this.isActive = true;
                    rechargeModeEnabled = false;
                    status = "";
                    repairCharge = 20;
                    timeAlive = 0;
                }
            }
        }