Example #1
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;
                            }
                        }
                    }
                }
            }
        }
Example #2
0
 public static bool PlayerBulletWithEnemy(PlayerBullet bullet, Sprite enemy)
 {
     return(IsSpriteCollision(bullet, enemy));
 }
Example #3
0
 public static bool PlayerBulletWithEnemy(PlayerBullet bullet, Sprite enemy)
 {
     return IsSpriteCollision(bullet, enemy);
 }
Example #4
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            spriteBatch = new SpriteBatch(ScreenManager.GraphicsDevice);
            spriteFont = ScreenManager.Game.Content.Load<SpriteFont>("Kootenay");

            soundEffect = ScreenManager.Game.Content.Load<SoundEffect>("kiss2");

            joey = new Sprite(ScreenManager.Game, "joey");
            monika = new Sprite(ScreenManager.Game, "monika");
            kiss = new PlayerBullet(ScreenManager.Game, "kiss");
            joey.Initialize();
            monika.Initialize();
            joey.position = new Vector2(600 - joey.texture.Width + joey.center.X, 300);
            monika.position = new Vector2(100, 300);
            kiss.forwardVector = new Vector2(-1, 0);

            monikaSpeed = new Vector2(0, 3);

            //Once the load has finished, we use ResetElapsedTime to tell the game's
            //timing mechanism that we have just finished a very long frame, and that
            //it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }
        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;
                        }
                    }
                }
            }
        }