private FlyingObject BulletToDodge() { Size size = source.Size; Point2D sourcePosition = source.Position; return(objectsToDodge .OfType <Bullet>() .Where(bullet => bullet.HorizontalSpeed > 0 && bullet.Position.X - Bullet.Size.Width / 2 < sourcePosition.X + size.Width / 2) .OrderByDescending(x => x.Position.X) .FirstOrDefault(bullet => bullet.Position.Y + Bullet.Size.Height / 2 > sourcePosition.Y - size.Height / 2 && bullet.Position.Y - Bullet.Size.Height / 2 < sourcePosition.Y + size.Height / 2 && IntersectionController.DistanceBetween(bullet, source) < fieldOfView)); }
private void CheckIntersections() { foreach (var source in flyingObjects) { if (IntersectionController.DoesTouchGround(source)) { source.HealthPoints = 0; } foreach (var target in flyingObjects) { if (source.Equals(target)) { continue; } if (IntersectionController.DoCirclesIntersect(source, target)) { //DeadObjects.Add(ship); IntersectionController.DamageOnIntersection(source, target); } } } }