Esempio n. 1
0
 private void Model_OnFrameUpdate(object sender, FrameEventArgs e)
 {
     Application.Current?.Dispatcher.Invoke(() =>
     {
         Asteroids.Clear();
         var sec     = e.Seconds % 60;
         var min     = e.Seconds / 60;
         ElapsedTime = min.ToString().PadLeft(2, '0') + ":" + sec.ToString().PadLeft(2, '0');
         foreach (Asteroid asteroid in e.Asteroids)
         {
             Asteroids.Add(asteroid);
         }
         Player = e.Player;
     });
 }
Esempio n. 2
0
        /// <summary>
        /// Спавнит/респавнит астероиды и аптечки
        /// </summary>
        private void Repopulate()
        {
            if (ASTEROIDS_COUNTER <= 0)
            {
                Asteroids.Clear();
                ASTEROIDS_COUNTER = ASTEROIDS_INITIAL_AMOUNT + 3;

                for (int i = 0; i <= ASTEROIDS_COUNTER; i++)
                {
                    int r = rnd.Next(5, 50);
                    Asteroids.Add(new Asteroid(new Point(Width + ASTEROIDS_X_SPAWNPOINT, rnd.Next(0, Height)), new Point(-r / 5, r), new Size(r, r)));
                }
            }


            if (_medKit == null)
            {
                Point p = new Point(40, rnd.Next(100, game.Height - 100));
                _medKit = new MedKit(p, new Point(), new Size(10, 10));
                GameLogger(console, "New medKit spawned at " + p);
            }
        }