Esempio n. 1
0
 public static void MoveStars(StarscapeModel starList)
 {
     foreach (var star in starList.Stars)
     {
         star.ShuntPosition();
     }
 }
Esempio n. 2
0
        public static void ConsiderAddingStar(double gameTimeSeconds, StarscapeModel StarsList, Random RandomGenerator)    // Quiz:  This is very similar to ConsiderAddingAlien().  What could you do about that?
        {
            var elapsedTime = gameTimeSeconds - StarsList.LastTimeWeConsideredAddingAStar;

            if (elapsedTime > StarscapeModel.TimeBetweenAddingStars)
            {
                if (StarsList.Stars.Count < StarscapeModel.MaxStarsOnScreenAtOnce)
                {
                    var starY   = RandomGenerator.Next(0, RetroScreen.HeightInPixels); // NB: Y axis runs the other way up from normal mathematics!
                    var speed   = RandomGenerator.Next(1, 4);
                    var newStar = new StarModel(new Point(RetroScreen.WidthInPixels, starY), speed);
                    StarsList.Stars.Add(newStar);
                }
                StarsList.LastTimeWeConsideredAddingAStar = gameTimeSeconds;  // Quiz:  Why are we doing this here?
            }
        }
Esempio n. 3
0
        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));
        }