private IEnumerator Start()
        {
            while (_cam == null)
            {
                yield return(null);

                _cam = MyGame.ThisInstance.Camera;
            }
        }
Exemple #2
0
        public BaseLevel(CaveLevelMapGameObject pCaveLevel, MCamera pCam)
        {
            _caveLevelMap = pCaveLevel;
            _cam          = (FollowCamera)pCam;

            AddChild(_caveLevelMap);

            var doorsManager = new DoorsManager(_caveLevelMap, this);

            AddChild(doorsManager);

            var memoriesManager = new HistoryPickupsManager(_caveLevelMap, this);

            AddChild(memoriesManager);

            var oilPickUpManager = new OilPickUpsManager(_caveLevelMap, this);

            AddChild(oilPickUpManager);

            var flashbacksTriggerManager = new FlashBackTriggersManager(_caveLevelMap, this);

            AddChild(flashbacksTriggerManager);

            var flashbackPickupsManager = new FlashbackPickupsManager(_caveLevelMap, this);

            AddChild(flashbackPickupsManager);

            var hiddenRoomManager = new HiddenRoomCoverManager(this);

            AddChild(hiddenRoomManager);

            var flashbacksManager = new FlashbackManager(this, flashbacksTriggerManager.FlashTriggersMap.Count);

            AddChild(flashbacksManager);



            var darkHallManager = new DarkHallManager(_caveLevelMap, this);

            AddChild(darkHallManager);

            var particlesManager = new ParticleManager();

            _player = new Player();
            AddChild(_player);

            var spawnPoint = GetPlayerSpawnPoint();

            _player.SetXY(spawnPoint.x, spawnPoint.y);

            AddChild(_cam);

            _cam.Target = _player;
            _cam.Map    = _caveLevelMap;
            _cam.SetXY(spawnPoint.x, spawnPoint.y);

            _playerCollision = new PlayerCollision(_player, _caveLevelMap, _cam);
            AddChild(_playerCollision);

            CoroutineManager.StartCoroutine(Start(), this);
        }
Exemple #3
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);
        }