public void HandleBulletCollisions(Player player, EnemyHandler enemies, SoundHandler sounds)
 {
     playerRectangle = new Rectangle((int)player.X, (int)player.Y, player.W, player.H);
     foreach (Enemy enemy in enemies.enemies)
             foreach (Bullet b in enemy.bullets)
                 if (b.Visible)
                 {
                     bulletRectangle = new Rectangle((int)b.X, (int)b.Y, 3, 3);
                     if (bulletRectangle.Intersects(playerRectangle))
                     {
                         b.Visible = false;
                         sounds.PlayHurt();
                         if (!player.Shield)
                         {
                             player.Hitpoints -= 10;
                         }
                         else
                         {
                             player.ShieldTime /= 2;
                         }
                     }
                 }
 }
Exemple #2
0
        protected override void Initialize()
        {
            currentLevel = 1;
            levelChanged = true;
            currentState = State.Start;

            player = new Player();
            items = new ItemHandler(this.Content);
            enemies = new EnemyHandler(this.Content);
            collisions = new CollisionHandler();
            sounds = new SoundHandler();

            base.Initialize();
        }