Beispiel #1
0
 public static IEnumerable <MovingBall> GetCollisionBalls(MovingBall ball, IEnumerable <MovingBall> balls)
 {
     return(balls.Where(x => ball.Distance(x, ball) < ball.Diameter && x.Color == Colors.Green));
 }
Beispiel #2
0
 public double Distance(MovingBall b1, MovingBall b2)
 {
     return(Math.Sqrt(Math.Pow(b2.PositionX - b1.PositionX, 2) + Math.Pow(b2.PositionY - b1.PositionY, 2)));
 }
Beispiel #3
0
 public int CollisionCount(MovingBall ball, IEnumerable <MovingBall> ballList)
 {
     return(ballList.Count(x => Distance(ball, x) < ball.Diameter));
 }