public override void FireShot()
{
if(ShotsFired < MaxShots || !Game.Match.UsePlayerTurns){
++ShotsFired;
Game.Services.GetService<SoundControl>().PlaySound(SoundControl.PistolSound);
var muzzle = SpriteGraphicsEffect.CreateMuzzle(
Game.Match.GameTime,
Ball.Position + 2f * Ball.AimDirection,
Ball.AimDirection.RotationFromDirection()
);
Game.Match.World.GraphicsEvents.Add(muzzle);
var rayHit = Game.Match.Physics.Raycast(Ball.Position, Ball.Position + Ball.AimDirection * 1000f);
if(rayHit.HasHit)
{
Game.Match.World.StaticGeometry.SubtractCircle(rayHit.Position.X, rayHit.Position.Y, ExplosionRadius);
Ballz.The().Match.World.GraphicsEvents.Add(SpriteGraphicsEffect.CreateExplosion(Ballz.The().Match.GameTime, rayHit.Position, 0, 0.2f));
if (rayHit.Entity != null)
{
if(rayHit.Entity is Ball)
{
Ball theBall = rayHit.Entity as Ball;
if (theBall.Health > 0)
theBall.ChangeHealth(-Damage);
}
}
}
}
}