Exemple #1
0
        /// <summary>
        ///     Removes all shots went out of bounds
        /// </summary>
        public void RemoveOutOfBoundShots(double playerShotsBound, double invadorShotBound)
        {
            var outOfBoundsPlayerShots = (from shot in PlayerShots
                                          where shot.Location.Y < playerShotsBound
                                          select shot).ToList();


            var outOfBoundsInvadersShots =
                (from shot in InvaderShots
                 where shot.Location.Y > invadorShotBound
                 select shot).ToList();

            if (outOfBoundsPlayerShots != null)
            {
                foreach (var shot in outOfBoundsPlayerShots)
                {
                    PlayerShots.Remove(shot);
                    TriggerShotMoved(shot, true);
                }
            }

            if (outOfBoundsInvadersShots == null)
            {
                return;
            }


            foreach (var shot in outOfBoundsInvadersShots)
            {
                InvaderShots.Remove(shot);
                TriggerShotMoved(shot, true);
            }
        }
Exemple #2
0
 /// <summary>
 ///     Removes all the shots from the screen
 /// </summary>
 public void RemoveShots()
 {
     foreach (var shot in PlayerShots.ToList())
     {
         PlayerShots.Remove(shot);
         TriggerShotMoved(shot, true);
     }
     foreach (var shot in InvaderShots.ToList())
     {
         InvaderShots.Remove(shot);
         TriggerShotMoved(shot, true);
     }
 }