Пример #1
0
        public override void Draw(ref SpriteBatch spriteBatch, GameTime gameTime)
        {
            //Draw the enemy's bullets
            for (int i = 0; i < NUM_BULLETS; i++)
            {
                //Cache current bullet to prevent constant lookup
                EnemyBullet _currentBullet = bullets[i];
                //Draw bullet to rotate based on player's rotation
                if (_currentBullet.isActive)
                {
                    _currentBullet.Draw(ref spriteBatch, gameTime);
                }
            }

            base.Draw(ref spriteBatch, gameTime);
        }
Пример #2
0
        }//end Update

        public void Shoot()
        {
            if (timeToNextFire <= 0)
            {
                for (int i = 0; i < NUM_BULLETS; i++)
                {
                    EnemyBullet _currentBullet = bullets[i];

                    if (_currentBullet.isActive == false)
                    {
                        //Let bullet shoot out of the top of the ship
                        _currentBullet.position      = new Vector2(position.X + bulletOffset, position.Y);
                        _currentBullet.rotation      = rotation;
                        _currentBullet.forwardVector = forwardVector;
                        _currentBullet.isActive      = true;
                        break;
                    }
                }

                //Start the countdown timer
                timeToNextFire = FIRE_DELAY;
            }
        }
Пример #3
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];
                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;
                        }
                    }
                }
            }
        }
Пример #4
0
 public static bool PlayerWithEnemyBullet(Sprite player, EnemyBullet enemyBullet)
 {
     return(IsSpriteCollision(player, enemyBullet));
 }
Пример #5
0
 public static bool PlayerWithEnemyBullet(Sprite player, EnemyBullet enemyBullet)
 {
     return IsSpriteCollision(player, enemyBullet);
 }