Exemple #1
0
        /// <summary>
        /// Метод создания массива космических объектов
        /// </summary>
        public static void Load()
        {
            _bullet = new Bullet(startBull, speedBull, sizeBull);

            _AsterObjs = new Asteroids[countAster];
            for (int i = 0; i < _AsterObjs.Length; i++)
            {
                startRandom = new Point(r.Next(0, Game.Width), r.Next(0, Game.Height));
                speedAster  = new Point(0, r.Next(5, 10));

                _AsterObjs[i] = new Asteroids(startRandom, speedAster, sizeAster);
            }

            _objs = new SpaseObject[countStars];
            for (int i = 0; i < _objs.Length; i++)
            {
                if (i == _objs.Length - 1)
                {
                    _objs[i] = new Moon(startMoon, speedMoon);
                }
                else
                {
                    startRandom = new Point(r.Next(0, Game.Width), r.Next(0, Game.Height));
                    if (speedStar.X > 0)
                    {
                        throw new GameObjectException("Летим в другую сторону!!!");
                    }
                    _objs[i] = new Stars(startRandom, speedStar, sizeStar);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Обновление экрана
        /// </summary>
        public static void Update()
        {
            foreach (SpaseObject obj in _objs)
            {
                obj.Update();
            }
            for (int i = 0; i < _AsterObjs.Length; i++)
            {
                _AsterObjs[i].Update();
                if (_AsterObjs[i].Collision(_bullet))
                {
                    startRandom   = new Point(r.Next(0, Game.Width), r.Next(0, Game.Height));
                    speedAster    = new Point(0, r.Next(5, 10));
                    _AsterObjs[i] = new Asteroids(startRandom, speedAster, sizeAster);

                    startRandom = new Point(r.Next(0, Game.Width), r.Next(0, Game.Height));
                    _bullet     = new Bullet(startRandom, speedBull, sizeBull);
                }
            }
            _bullet.Update();
        }