コード例 #1
0
 // 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);
         }
     }
 }
コード例 #2
0
        // 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);
        }