public static void RemoveCompletedExplosions(double gameTimeSeconds, ExplosionListModel explosionsList) { explosionsList.Explosions.RemoveAll(explosion => { var elapsedSinceExplosionStart = gameTimeSeconds - explosion.StartTime; return(elapsedSinceExplosionStart > ExplosionModel.ExplosionDurationSeconds); }); }
public static void DestroyShip(double gameTimeSeconds, ShipModel ship, ExplosionListModel explosions, GameSounds gameSounds) { ship.IsDestroyed = true; ship.TimeOfDestruction = gameTimeSeconds; AddExplosion(gameTimeSeconds, ship.CentrePoint, explosions, gameSounds); }
public static void CheckIfShipShot(double gameTimeSeconds, ShipModel ship, AlienListModel aliensList, AlienBulletListModel alienBulletList, ExplosionListModel explosions, GameSounds gameSounds) { if (!ship.IsDestroyed) { bool shipDestroyed = alienBulletList.AlienBullets.Exists(b => CollisionDetection.Hits(b.CentrePoint, ship.CentrePoint, CollisionDetectRange)) || aliensList.Aliens.Exists(a => CollisionDetection.Hits(a.CentrePoint, ship.CentrePoint, CollisionDetectRange)); if (shipDestroyed) { DestroyShip(gameTimeSeconds, ship, explosions, gameSounds); } } }
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 AddExplosion(double gameTimeSeconds, Point explosionCentre, ExplosionListModel explosionList, GameSounds gameSounds) { explosionList.Explosions.Add(new ExplosionModel(explosionCentre, gameTimeSeconds)); gameSounds.ExplosionSound.Play(); }