// Remove balls that are no longer touching the powerup. public void FilterBalls() { for (int i = BallsInside.Count - 1; i >= 0; --i) { if (!CheckCollision(BallsInside.ElementAt(i))) { BallsInside.RemoveAt(i); } } }
// Called only if a ball is touching with the powerUp. // If the ball is in the list then the ball has already activated the powerUp. // If the ball is not in the list, the powerUp will be activated and the ball added in the list. public bool ActivatePowerUp(Ball ball) { if (BallsInside.Contains(ball)) { return(false); } IsUsed = true; BallsInside.Add(ball); FilterBalls(); return(true); }