Beispiel #1
0
        public static void Load()
        {
            List <VisualObject> game_objects = new List <VisualObject>();

            for (var i = 0; i < 40; i++)
            {
                game_objects.Add(new Star(
                                     new Point(600, (int)(i / 2.0 * 20)),
                                     new Point(-i, 0),
                                     2));
            }

            __Asteroids = Asteroid.NewAsteroidCollection(
                new Random(),
                Game.Width, Game.Height,
                asteroid_max_speed,
                asteroid_count,
                asteroid_size);

            const int med_count = 5;

            for (var i = 0; i < med_count; i++)
            {
                game_objects.Add(__MedicineChest = new MedicineChest(
                                     new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                     new Point(-rnd.Next(1, asteroid_max_speed), 0),
                                     new Size(30, 30)));
            }
            __GameObjects = game_objects.ToArray();

            __SpaceShip            = new SpaceShip(new Point(10, 400), new Point(5, 5), new Size(10, 10));
            __SpaceShip.Destroyed += OnShipDestroyed;
            __Logger += LoggerConsole;
            __Logger += LoggerFile;
        }
Beispiel #2
0
        /// <summary>
        /// Load main scene
        /// </summary>
        ///
        public static void Load()
        {
            var game_objects = new List <VisualObject>();

            // stars
            const int stars_count    = 150;
            const int star_size      = 5;
            const int star_max_speed = 20;

            for (var i = 0; i < stars_count; i++)
            {
                game_objects.Add(new Star(
                                     new Point(__rnd.Next(0, Width), __rnd.Next(0, Height)),
                                     new Point(-__rnd.Next(0, star_max_speed), 0),
                                     star_size));
            }

            // asteroids
            game_objects.AddRange(CreateAsteroids(asteroids_count));

            // medkit
            game_objects.AddRange(CreateMedKit(medkit_count));

            __GameObjects = game_objects.ToArray();
            //__Bullet = new Bullet(200);
            __Bullets             = new List <Bullet>();
            __Ship                = new SpaceShip(new Point(10, 400), new Point(5, 5), new Size(10, 10));
            __Ship.ShipDestroyed += OnShipDestroyed;
            __Ship.ShipOnState   += OnShipOnState;
        }
Beispiel #3
0
        private static List <Bullet> __Bullets = new List <Bullet>(); // создали список пуль

        public static void Load()
        {
            Log?.Invoke($"Загрузка данных сцены...");

            var game_objects = new List <VisualObject>();

            __AsteroidList = new List <VisualObject>();


            const int star_count     = 100;
            const int star_size      = 5;
            const int star_max_speed = 20;

            for (int i = 0; i < star_count; i++)
            {
                game_objects.Add(new Star(new Point(rnd.Next(0, Width),
                                                    rnd.Next(0, Height)), new Point(rnd.Next(0, star_max_speed), 0),
                                          star_size));
            }
            Log?.Invoke($"Созданы звезды. Количество {star_count}");

            AsteroidListCreate(__AsteroidList, rnd);
            Log?.Invoke($"{Level.NameLevelGame}\nАстероидов создано {__AsteroidList.Count}\n");


            __GameObjects  = game_objects.ToArray();
            __AsteroidList = __AsteroidList.ToList();

            __Ship = new SpaceShip(new Point(10, 300), new Point(5, 5), 40);
            __Ship.ShipDestroyed += OnShipDestroyed;

            Log?.Invoke($"Загрузка данных сцены выполнена успешно.");
        }
Beispiel #4
0
        public static void Load()
        {
            var game_objects = new List <VisualObject>();
            var rnd          = new Random();

            const int stars_count    = 150;
            const int star_size      = 6;
            const int star_max_speed = 20;

            for (var i = 0; i < stars_count; i++)
            {
                game_objects.Add(new Star(
                                     new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                     new Point(rnd.Next(0, star_max_speed), 0),
                                     star_size));
            }

            //const int asteroids_count = 15;
            //const int asteroid_size = 25;
            //const int asteroid_max_speed = 20;
            for (var i = 0; i < asteroids_count; i++)
            {
                __Asteroids.Add(new Asteroid(
                                    new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                    new Point(-rnd.Next(0, asteroid_max_speed), 0),
                                    asteroid_size));
            }

            __GameObjects = game_objects.ToArray();

            __SpaceShip = new SpaceShip(new Point(10, 400), new Point(5, 5), new Size(20, 20));
            __SpaceShip.ShipDestroyed += OnShipDestroyed;
        }
Beispiel #5
0
        private static void LoadObjects()
        {
            // Создаёс космос
            var stars_count = 150;
            var space       = new Space(stars_count);

            RegisterGameObject(space);

            // Создаём оружие
            var weapon = new Weapon();

            RegisterGameObject(weapon);

            // Создаём игрока
            var ship_position = new Point(10, Height / 2);
            var ship_size     = new Size(100, 60);

            Player = new SpaceShip(ship_position, ship_size, weapon);
            RegisterGameObject(Player);

            // Создаём респаун астероидов
            var respawn_place     = new Rectangle(Width, 50, 10, Height - 100);
            var asteroids_speed   = new Point(-7, 0);
            var span_timeout      = 40;
            var asteroids_respawn = new AsteroidsRespawn(respawn_place, asteroids_speed, span_timeout);

            RegisterGameObject(asteroids_respawn);

            // Создаём датчики здоровья и очков
            var player_stats = new PlayerStats(Player);

            RegisterGameObject(player_stats);
        }
Beispiel #6
0
        //private static Heal __Heal;
        //private static VisualObject[] __GameObjectsSmall;
        public static void Load()
        {
            Log?.Invoke("Загрузка данных сцены...");

            var game_objects = new List <VisualObject>();
            var star_obj     = new List <VisualObject>();

            var rnd = new Random();

            const int stars_count     = 160;
            const int stars_size      = 5;
            const int stars_max_speed = 20;


            for (var i = 0; i < stars_count; i++)
            {
                game_objects.Add(new Star(
                                     new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                     new Point(-rnd.Next(0, stars_max_speed)),
                                     stars_size));
            }
            Log?.Invoke("Созданы звезды");


            const int starIm_count     = 2;
            const int starIm_size      = 45;
            const int starIm_max_speed = 20;


            for (var i = 0; i < starIm_count; i++)
            {
                star_obj.Add(new StarIm(
                                 new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                 new Point(-rnd.Next(0, starIm_max_speed)),
                                 starIm_size));
            }
            Log?.Invoke($"Больших звезд создано {starIm_count}");


            const int heal_count     = 2;
            const int heal_size      = 30;
            const int heal_max_speed = 20;

            for (var i = 0; i < heal_count; i++)
            {
                game_objects.Add(new Heal(
                                     new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                     new Point(-rnd.Next(0, heal_max_speed)),
                                     heal_size));
            }

            __GameObjects         = game_objects.ToArray();
            __StarObjects         = star_obj.ToArray();
            __Bullet              = new Bullet(200);
            __Ship                = new SpaceShip(new Point(10, 400), new Point(5, 5), new Size(10, 10));
            __Ship.ShipDestroyed += OnShipDestroyed;

            Log?.Invoke("Загрузка данных сцены выполнена успешнo.");
        }
Beispiel #7
0
        /// <summary> Загрузка игровых объектов</summary>
        public static void Load()
        {
            Log?.Invoke("Загрузка данных сцены...");

            List <VisualObject> game_objects = new List <VisualObject>();

            __GameObjects = new VisualObject[30];

            const int star_count     = 150;
            const int star_size      = 5;
            const int star_max_speed = 20;
            Random    rnd            = new Random();

            for (int i = 0; i < star_count; i++)   //звездный фон
            {
                game_objects.Add(new Star(
                                     new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                     new Point(-rnd.Next(0, star_max_speed), 0),
                                     star_size));
            }
            Log?.Invoke("Создание звезд");

            const int asteroid_count     = 15;
            const int asteroid_size      = 30;
            const int asteroid_max_speed = 20;

            for (int i = 0; i < asteroid_count; i++)
            {
                game_objects.Add(new Asteroid(
                                     new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                     new Point(-rnd.Next(0, asteroid_max_speed), 0),
                                     asteroid_size));
            }
            Log?.Invoke("Создание астероиды");


            __GameObjects = game_objects.ToArray();

            __SpaceShip            = new SpaceShip(new Point(10, 400), new Point(5, 5), new Size(10, 10));
            __SpaceShip.Destroyed += OnShipDestroyed;

            Log?.Invoke("Загрузка данных сцены выполнена");
        }
Beispiel #8
0
        public static void Load()
        {
            var game_objects = new List <VisualObject>();

            //рисуем задний фон
            const int start_count    = 150;
            const int star_size      = 20;
            const int star_max_speed = 20;

            for (var i = 0; i < start_count; i++)
            {
                game_objects.Add(new Star(
                                     new Point(random.Next(0, Width), random.Next(0, Height)),
                                     new Point(-1 * random.Next(1, star_max_speed), 0),
                                     star_size));
            }

            //добавляем астероиды
            __Asteroids = Asteroid.NewAsteroidCollection(
                new Random(),
                Game.Width, Game.Height,
                asteroid_max_speed,
                asteroid_count,
                asteroid_max_size);

            const int apteka_count = 10;

            for (var i = 0; i < apteka_count; i++)
            {
                __Aptekas.Add(new Apteka(
                                  new Point(random.Next(0, Width), random.Next(0, Height)),
                                  new Point(-1 * random.Next(1, asteroid_max_speed), 0),
                                  new Size(30, 30)));
            }

            __GameObjects = game_objects.ToArray();

            __Ship = new SpaceShip(new Point(10, 200), new Point(5, 5), new Size(10, 10));
            __Ship.ShipDestroyed += OnShipDestroyed;

            __Logger += LoggerConsole;
            __Logger += LoggerFile;
        }
Beispiel #9
0
        public static void Load()
        {
            List <VisualObject> game_objects = new List <VisualObject>();

            //for (var i = 0; i < 30; i++)
            //{
            //    game_objects.Add(new VisualObject(
            //        new Point(600, i * 20),
            //        new Point(15 - i, 20 - i),
            //        new Size(20, 20)));
            //}

            for (var i = 0; i < 10; i++)
            {
                game_objects.Add(new Star(
                                     new Point(600, (int)(i / 2.0 * 20)),
                                     new Point(-i, 0),
                                     10));
            }

            var       rnd                = new Random();
            const int asteroid_count     = 10;
            const int asteroid_size      = 25;
            const int asteroid_max_speed = 20;

            for (var i = 0; i < asteroid_count; i++)
            {
                game_objects.Add(new Asteroid(
                                     new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                     new Point(-rnd.Next(0, asteroid_max_speed), 0),
                                     asteroid_size));
            }

            game_objects.Add(new Asteroid(new Point(Width / 2, 200), new Point(-asteroid_max_speed, 0), asteroid_size));

            //__Bullet = new Bullet(200);
            __GameObjects = game_objects.ToArray();

            __SpaceShip            = new SpaceShip(new Point(10, 400), new Point(5, 5), new Size(10, 10));
            __SpaceShip.Destroyed += OnShipDestroyed;
        }
Beispiel #10
0
        public static void Load()
        {
            Log?.Invoke("Загрузка данных сцены...");

            var game_objects = new List <VisualObject>();
            var rnd          = new Random();

            const int stars_count    = 150;
            const int star_size      = 5;
            const int star_max_speed = 20;

            for (var i = 0; i < stars_count; i++)
            {
                game_objects.Add(new Star(
                                     new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                     new Point(-rnd.Next(0, star_max_speed), 0),
                                     star_size));
            }
            Log?.Invoke($"Создано звёзд {stars_count}");

            const int asteroids_count    = 10;
            const int asteroid_size      = 25;
            const int asteroid_max_speed = 20;

            for (var i = 0; i < asteroids_count; i++)
            {
                game_objects.Add(new Asteroid(
                                     new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                     new Point(-rnd.Next(0, asteroid_max_speed), 0),
                                     asteroid_size));
            }
            Log?.Invoke($"Астероидов создано {asteroids_count}");

            __GameObjects = game_objects.ToArray();
            //__Bullet = new Bullet(200);
            __Ship = new SpaceShip(new Point(10, 400), new Point(5, 5), new Size(10, 10));
            __Ship.ShipDestroyed += OnShipDestroyed;

            Log?.Invoke("Загрузка данных сцены выполнена успешно");
        }
Beispiel #11
0
        public static void Load()
        {
            #region old code
            //    List<VisualObject> game_objects = new List<VisualObject>();

            //    //for (var i = 0; i < 30; i++)
            //    //{
            //    //    game_objects.Add(new Asteroid(
            //    //        new Point(600, i * 20),
            //    //        new Point(15 - i, 20 - i),
            //    //        30));
            //    //}

            //    for (var i = 0; i < 12; i++)
            //    {
            //        game_objects.Add(new Star(
            //            //new Point(300, (int)(i * 50)),
            //    new Point(rnd.Next(60, Width), rnd.Next(0, Height)),
            //            new Point(-i, 0),
            //            new Size(40, 30)));
            //}

            //const int asteroid_count = 10;
            //    //const int asteroid_size = 25;
            //    //const int asteroid_max_speed = 20;

            //    for (var i = 0; i < asteroid_count; i++)
            //        game_objects.Add(new Asteroid(
            //            new Point(rnd.Next(60, Width), rnd.Next(0, Height)),
            //            new Point(-rnd.Next(0, _ObjectMaxSpeed), 0),
            //            _ObjectSize));

            //    //game_objects.Add(
            //    //    new Asteroid(new Point(Width / 2, 200),
            //    //    new Point(-asteroid_max_speed, 0),
            //    //    asteroid_size));

            //    //__Bullet = new Bullet(200);

            //    __PowerAid = new PowerAid(
            //        new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
            //        new Point(-rnd.Next(0, _ObjectMaxSpeed), 10),
            //        _ObjectSize);

            //    __GameObjects = game_objects.ToArray();
            #region Array VirtualObject
            //__GameObjects = new VisualObject[30];
            //for (int i = 0; i < __GameObjects.Length / 2; i++)
            //{
            //    __GameObjects[i] = new VisualObject(
            //        new Point(600, i * 20),
            //        new Point(15 - i, 20 - i),
            //        new Size(20, 20));
            //}

            //for (int i = __GameObjects.Length / 2; i < __GameObjects.Length; i++)
            //{
            //    __GameObjects[i] = new Star(
            //        new Point(600, i * 20),
            //        new Point(-i, 0),
            //        new Size(20, 20));
            //}
            #endregion
            #endregion

            for (int a = 0; a < _AsteroidCount; a++)
            {
                __Asteroids.Add(new Asteroid(
                                    new Point(_Random.Next(60, Width), _Random.Next(0, Height - _ObjectSize)),
                                    new Point(-_Random.Next(1, _ObjectMaxSpeed), 0),
                                    _Random.Next(_ObjectSize - 5, _ObjectSize + 10)));
            }

            for (int s = 0; s < _StarCount; s++)
            {
                __Stars.Add(new Star(
                                new Point(_Random.Next(60, Width), _Random.Next(0, Height - _ObjectSize)),
                                new Point(-_Random.Next(1, _ObjectMaxSpeed), 0),
                                new Size(_ObjectSize, _ObjectSize)));
            }

            for (int p = 0; p < _PowerAidCount; p++)
            {
                __PowerAids.Add(new PowerAid(
                                    new Point(_Random.Next(0, Width), _Random.Next(0, Height - _ObjectSize)),
                                    new Point(-_Random.Next(1, _ObjectMaxSpeed), 0),
                                    _ObjectSize));
            }

            //__Asteroids.ToArray();
            //__Stars.ToArray();//может сразу сделать массив?
            //__PowerAids.ToArray();

            __SpaceShip = new SpaceShip(
                new Point(20, 400),
                new Point(10, 10),
                _ObjectSize * 2);
            __SpaceShip.Destroyed += OnShipDestroyed;
        }