Пример #1
0
        public Level(FollowCamera pCam, MapGameObject pMap)
        {
            _cam = pCam;
            _map = pMap;

            var enemiesSoundManager = new EnemiesSoundManager();

            AddChild(enemiesSoundManager);

            var spawnPointObject = _map.ObjectGroup.Objects.FirstOrDefault(o => o.Name == "spawn point");

            _spawnPoint = new Vector2(spawnPointObject.X, spawnPointObject.Y);

            AddChild(_map);

            //Create delivery points
            var deliveryPointObjects = _map.ObjectGroup.Objects.Where(o => o.Name.StartsWith("delivery point"))
                                       .OrderBy(o => o.Name);

            _deliveryPoints = new DeliveryPoint[deliveryPointObjects.Count()];

            int dCounter = 0;

            foreach (var deliveryPointObj in deliveryPointObjects)
            {
                uint deliveryTimer = (uint)(deliveryPointObj.GetIntProperty("timer", 60) * 1000);

                var deliveryPoint = new DeliveryPoint(deliveryPointObj.X, deliveryPointObj.Y,
                                                      deliveryPointObj.Width, deliveryPointObj.Height, deliveryTimer);
                AddChild(deliveryPoint);

                deliveryPoint.SetActive(false);

                _deliveryPoints[dCounter] = deliveryPoint;
                dCounter++;
            }

            //Enable the first delivery point
            _deliveryPoints[0].SetActive(true);


            //Add Tornados
            _tornadoesManager = new TornadoManager(this, enemiesSoundManager);
            AddChild(_tornadoesManager);

            _tornadoesManager.SpawnTornadoes();

            float storkMaxSpeed = spawnPointObject.GetFloatProperty("speed", 200);

            _stork = new Stork(storkMaxSpeed)
            {
                x        = _spawnPoint.x,
                y        = _spawnPoint.y,
                rotation = spawnPointObject.rotation
            };

            AddChild(_stork);
            _stork.SetScaleXY(1.5f, 1.5f);

            _storkManager = new StorkManager(_stork, this);
            AddChild(_storkManager);

            _stork.IUpdater = _storkManager;

            var hunterBulletManager = new HunterBulletManager(this);

            AddChild(hunterBulletManager);

            _huntersManager = new HuntersManager(this, hunterBulletManager);
            _huntersManager.SpawnHunters();
            _huntersManager.SetHuntersTarget(_stork);

            _dronesesManager = new DronesManager(this, enemiesSoundManager);
            _dronesesManager.SpawnDrones();

            _dronesesManager.SetDronesTarget(_stork);

            for (int i = 0; i < _pizzasPool.Length; i++)
            {
                var pizza = new PizzaGameObject("data/pizza00.png");
                pizza.visible = false;
                this.AddChild(pizza);

                _pizzasPool[i] = pizza;
            }

            _airplanesManager = new AirplanesManager(this, enemiesSoundManager);
            _airplanesManager.SpawnAirplanes();

            AddChild(_airplanesManager);

            _map.DrawBorders(this, 0.5f);

            _cloudsManager = new CloudsManager(_map, this);
            AddChild(_cloudsManager);

            _cloudsManager.SpawnClouds();

            CoroutineManager.StartCoroutine(SetCamTargetRoutine(_stork), this);

            AddChild(_cam);
            _cam.Map = _map;
            _cam.SetXY(_map.MapWidthInPixels * 0.5f, _map.MapHeightInPixels * 0.5f);
            _cam.Start();

            _cam.AddChild(HudScreenFader.instance);
            HudScreenFader.instance.SetXY(-game.width * 0.5f, -game.height * 0.5f);

            _hud = new HUD(_cam, _stork);
        }
Пример #2
0
 public HuntersManager(Level pLevel, HunterBulletManager pHunterBulletManager) : base(false)
 {
     _level         = pLevel;
     _bulletManager = pHunterBulletManager;
     _hunters       = new List <HunterGameObject>();
 }