public static void MoveShipBullets(ShipBulletListModel shipBulletsList)
 {
     foreach (var shipBullet in shipBulletsList.ShipBullets)
     {
         shipBullet.ShuntPosition();
     }
 }
        public static void RemoveOffScreenObjects(AlienListModel aliensList, ShipBulletListModel shipBulletList, AlienBulletListModel alienBulletList, StarscapeModel starList, ScoreModel scoring)
        {
            shipBulletList.ShipBullets.RemoveAll(b => b.CentrePoint.x > RetroScreen.WidthInPixels);
            alienBulletList.AlienBullets.RemoveAll(b => b.CentrePoint.x < 0);
            starList.Stars.RemoveAll(s => s.CentrePoint.x < 0);
            int numberOfAliensRemoved = aliensList.Aliens.RemoveAll(a => a.CentrePoint.x < 0);

            scoring.SetScore(Math.Max(0, scoring.Score - numberOfAliensRemoved));
        }
 public static void ConsiderPlayerFiring(double gameTimeSeconds, Input input, ShipBulletListModel shipBulletList, ShipModel ship, GameSounds gameSounds)
 {
     if (!ship.IsDestroyed && input.Fire.JustDown)
     {
         var elapsedTime = gameTimeSeconds - ship.MostRecentPlayerFiringTime;
         if (elapsedTime > ShipModel.MinFiringIntervalForPlayer)
         {
             shipBulletList.ShipBullets.Add(new ShipBulletModel(ship.CentrePoint.ShuntedBy(ship.Width, 0)));
             ship.MostRecentPlayerFiringTime = gameTimeSeconds; // Quiz:  Why are we doing this?
             gameSounds.PlayerFiringSound.Play();
         }
     }
 }
 public static void CheckIfAlienShot(double gameTimeSeconds, AlienListModel alienList, ShipBulletListModel shipBulletsList, ExplosionListModel explosionsList, ScoreModel Scoring, GameSounds gameSounds)
 {
     CheckIfAlienShotAndThen(
         gameTimeSeconds, alienList, shipBulletsList, alien =>
     {
         AddExplosion(gameTimeSeconds, alien.CentrePoint, explosionsList, gameSounds);
         Scoring.SetScore(Scoring.Score + 1);
     });
 }
        public static void CheckIfAlienShotAndThen(double gameTimeSeconds, AlienListModel alienList, ShipBulletListModel shipBulletsList, Action <AlienModel> andThen)
        {
            var bulletsToRemove = new List <ShipBulletModel>();
            var aliensToRemove  = new List <AlienModel>();

            foreach (var bullet in shipBulletsList.ShipBullets)
            {
                foreach (var alien in alienList.Aliens)
                {
                    if (CollisionDetection.Hits(bullet.CentrePoint, alien.CentrePoint, CollisionDetectRange))    // Quiz:  This design means hitting NEAR the centre of the alien!
                    {
                        bulletsToRemove.Add(bullet);
                        aliensToRemove.Add(alien);
                        andThen(alien);
                    }
                }
            }

            alienList.Aliens.RemoveAll(a => aliensToRemove.Contains(a));
            shipBulletsList.ShipBullets.RemoveAll(b => bulletsToRemove.Contains(b));
        }