Beispiel #1
0
        /// <summary>
        /// Draw the ships in the fleet.
        /// </summary>
        /// <param name="spriteBatch"></param>
        /// <param name="gameTime"></param>
        public void Draw(ref SpriteBatch spriteBatch, GameTime gameTime)
        {
            //Draw ships
            for (int i = 0; i < shipList.Count; i++)
            {
                //Cache ship sprite
                Gryffon curShip = shipList[i];

                if (curShip.isActive)
                {
                    curShip.Draw(ref spriteBatch, gameTime);

                    //Draw some identifier to keep track of ships
                    spriteBatch.DrawString(Defines.spriteFontKootenay, i.ToString(), curShip.position, Defines.textColor);
                }
            }

            //Draw the formation manager's global fixed point
            formationManager.Draw(ref spriteBatch, gameTime);
        }
Beispiel #2
0
        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;
                        }
                    }
                }
            }
        }