public bool IsBallInGoal(Ball ball) { bool ret = false; if ( ball.Position.X > NWPoint.X && ball.Position.X < NEPoint.X && ball.Position.Y > NWPoint.Y && ball.Position.Y < SWPoint.Y) { bool wasInFrontOfGoal = false; if (this.ID == 1) //left goal { wasInFrontOfGoal = (ball.X - ball.TranslateVelocity.X > SEPoint.X); } else { wasInFrontOfGoal = (ball.X - ball.TranslateVelocity.X < NWPoint.X); } if (wasInFrontOfGoal) { if (!ball.IsBallInGoal) { ball.LastGoalID = ID; ball.IsBallInGoal = true; subscriber.BallEnteredGoal(this, ball); } ret = true; } else { ret = false; } } else { if (ball.IsBallInGoal && ball.LastGoalID == ID) { ball.IsBallInGoal = false; subscriber.BallLeftGoal(this, ball); } } return(ret); }