Exemplo n.º 1
0
        public void Collision(Player player)
        {
            Rectangle bulletCollisionBox;

            Santa attacker = player as Santa;
            if (attacker == null)
            {
                return;
            }

            if (player.CollisionBox.TouchAnywhere(this.CollisionBox))
            {
                player.Health -= 1;
            }

            for (int i = 0; i < attacker.BulletFactory.GeneratedBullets.Count; i++)
            {
                bulletCollisionBox = new Rectangle(attacker.BulletFactory.GeneratedBullets[i].PositionX,
                    attacker.BulletFactory.GeneratedBullets[i].PositionY,
                    attacker.BulletFactory.GeneratedBullets[i].ProjectileTexture.Width,
                    attacker.BulletFactory.GeneratedBullets[i].ProjectileTexture.Height);

                if (bulletCollisionBox.TouchAnywhere(this.CollisionBox))
                {
                    this.Health -= (int)player.Damage;
                    attacker.BulletFactory.GeneratedBullets.Remove(attacker.BulletFactory.GeneratedBullets[i]);
                }

            }
        }
Exemplo n.º 2
0
        public override void Collision(Rectangle newRectangle)
        {
            base.Collision(newRectangle);

            Rectangle bulletCollisionBox;

            for(int i = 0; i < this.bulletFactory.GeneratedBullets.Count; i++)
            {
                bulletCollisionBox = new Rectangle(this.bulletFactory.GeneratedBullets[i].PositionX,
                    this.bulletFactory.GeneratedBullets[i].PositionY,
                    this.bulletFactory.GeneratedBullets[i].ProjectileTexture.Width,
                    this.bulletFactory.GeneratedBullets[i].ProjectileTexture.Height);

                if (bulletCollisionBox.TouchAnywhere(newRectangle))
                {
                    this.bulletFactory.GeneratedBullets.Remove(this.bulletFactory.GeneratedBullets[i]);
                }

            }
        }