/// <summary> /// Создаем массив из 191 объекта и далее запускаем их со сдвигом позиции /// </summary> public virtual void Load() { _bullet = new Bullet(new Point(0, 200), new Point(5, 0), new Size(4, 1)); _asteroids = new Asteroid[3]; _objs = new BaseObject[191]; Random rnd1 = new Random(DateTime.Now.Millisecond); Random rnd2 = new Random(DateTime.Now.Millisecond + 1); int dir_X, dir_Y; for (int i = 0; i < 30; i++) { _objs[i] = new Square(new Point(i * 5, i * 5), new Point(20, 20), new Size(1, 1)); } for (int i = 30; i < 190; i++) { dir_X = rnd1.Next(-20, 20); dir_Y = rnd2.Next(-20, 20); _objs[i] = new Rain(new Point(Game.Width / 2, Game.Height / 2), new Point(dir_X, dir_Y), new Size(1, 1)); } for (int i = 190; i < 191; i++) { _objs[i] = new Planet(new Point(300, 300), new Point(rnd1.Next(1, 10), rnd2.Next(1, 10)), new Size(50, 50)); } for (var i = 0; i < _asteroids.Length; i++) { int r = rnd1.Next(5, 50); _asteroids[i] = new Asteroid(new Point(600, rnd1.Next(0, Game.Height)), new Point(-r / 5, r), new Size(r, r)); } }
/// <summary> /// Создаем массив из 191 объекта и далее запускаем их со сдвигом позиции /// </summary> public virtual void Load() { _ship = new Ship(new Point(10, 400), new Point(5, 5), new Size(10, 10)); //добавляем корабль _bullet = new Bullet(new Point(10, 400), new Point(20, 0), new Size(4, 1)); //добавляем пулю _asteroids = new Asteroid[3]; //добавляем 3 астериода _kits = new Kit[2]; // добавялем 2 аптечки _objs = new BaseObject[191]; // делаем 2 типа рандома, чтобы сгенерировать разные траектории полета Random rnd1 = new Random(DateTime.Now.Millisecond); Random rnd2 = new Random(DateTime.Now.Millisecond + 1); int dir_X, dir_Y; for (int i = 0; i < 30; i++) { _objs[i] = new Square(new Point(i * 5, i * 5), new Point(20, 20), new Size(1, 1)); } for (int i = 30; i < 190; i++) { dir_X = rnd1.Next(-20, 20); dir_Y = rnd2.Next(-20, 20); _objs[i] = new Rain(new Point(Game.Width / 2, Game.Height / 2), new Point(dir_X, dir_Y), new Size(1, 1)); } for (int i = 190; i < 191; i++) { _objs[i] = new Planet(new Point(300, 300), new Point(rnd1.Next(1, 10), rnd2.Next(1, 10)), new Size(50, 50)); } for (var i = 0; i < _asteroids.Length; i++) { int r = rnd1.Next(5, 50); _asteroids[i] = new Asteroid(new Point(600, rnd1.Next(0, Game.Height)), new Point(-r / 5, r), new Size(r, r)); } for (var i = 0; i < _kits.Length; i++) { int r = rnd1.Next(15, 20); _kits[i] = new Kit(new Point(600, rnd1.Next(0, Game.Height)), new Point(-r / 5, r), new Size(r, r)); } }