private IEnumerator PlayCoinsExplosionRoutine(Stork stork) { int time = 0; int duration = 1200; yield return(null); _cartoonCoinsExplosion.SetActive(true); stork.AddChild(_cartoonCoinsExplosion); _cartoonCoinsExplosion.SetXY(0, 0); _cartoonCoinsExplosion.alpha = 1f; SpriteTweener.TweenAlpha(_cartoonCoinsExplosion, 1, 0, duration - 500, null, 500); while (time < duration) { float fFrame = Mathf.Map(time, 0, duration, 0, _cartoonCoinsExplosion.frameCount - 1); int frame = Mathf.Round(fFrame) % _cartoonCoinsExplosion.frameCount; _cartoonCoinsExplosion.SetFrame(frame); time += Time.deltaTime; yield return(null); } yield return(new WaitForMilliSeconds(200)); stork.RemoveChild(_cartoonCoinsExplosion); _cartoonCoinsExplosion.SetActive(false); }
private IEnumerator ShowSmokeOnStork00Routine(Stork stork) { int time = 0; int duration = 1500; yield return(null); _smoke00.visible = true; stork.AddChild(_smoke00); _smoke00.SetXY(0, 0); _smoke00.alpha = 1f; SpriteTweener.TweenAlpha(_smoke00, 1, 0, duration - 500, null, 500); while (time < duration) { float fFrame = Mathf.Map(time, 0, duration, 0, _smoke00.frameCount - 1); int frame = Mathf.Round(fFrame) % _smoke00.frameCount; _smoke00.SetFrame(frame); time += Time.deltaTime; yield return(null); } yield return(new WaitForMilliSeconds(200)); stork.RemoveChild(_smoke00); _smoke00.visible = false; }
private IEnumerator SetCamTargetRoutine(Stork stork) { yield return(new WaitForMilliSeconds(500)); _cam.Target = stork; _cam.TargetFrontDistance = 200; }
public void SetHuntersTarget(Stork stork) { for (int i = 0; i < _hunters.Count; i++) { _hunters[i].Enemy = stork; } }
public StorkManager(Stork pStork, Level pLevel) : base(false) { _stork = pStork; _level = pLevel; _map = _level.Map; _stork.ColliderListener = this; _lastMarker = _level.GetChildren(false).Where(o => o is DeliveryPoint).LastOrDefault(); }
public void PlayCoinsExplosion(Stork stork) { CoroutineManager.StopCoroutine(_cartoonCoinsExplosionRoutine); _cartoonCoinsExplosionRoutine = CoroutineManager.StartCoroutine(PlayCoinsExplosionRoutine(stork), this); }
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); }
void IColliderListener.OnCollisionWith(Stork stork, GameObject other) { if (!_inCollisionWithDeliveryPoint && other is DeliveryPoint) { if (!_level.IsLevelEnding) { //Pizza delivered LocalEvents.Instance.Raise(new LevelLocalEvent(_level, LevelLocalEvent.EventType.PIZZA_DELIVERED)); SoundManager.Instance.PlayFx(5); //Drop the pizza to the center of the delivery point var dropPoint = new Vector2(other.x, other.y); CoroutineManager.StartCoroutine(DropPizzaRoutine(dropPoint), this); } _inCollisionWithDeliveryPoint = true; CoroutineManager.StartCoroutine(WaitDeliveryPointBeDisabled(other), this); } else if (!_stork.IsCollisionDisabled && !_inCollisionWithAirplane && other is CompoundCollider && other.parent is Airplane parent && parent != _lastAirplaneCollided) { _inCollisionWithAirplane = true; _lastAirplaneCollided = parent; SoundManager.Instance.PlayFx(6); //Lose Pizza CoroutineManager.StartCoroutine(CollisionWithAirplaneRoutine(parent), this); } if (!_stork.IsCollisionDisabled && !_inCollisionWithDrone && other is DroneGameObject drone && drone != _lastDroneCollided && drone.State != DroneGameObject.DroneState.RETURN_TO_START_POINT_AFTER_HIT) { _lastDroneCollided = drone; _inCollisionWithDrone = true; SoundManager.Instance.PlayFx(6); //Lose Pizza CoroutineManager.StartCoroutine(CollisionWithDroneRoutine(drone), this); } if (!_stork.IsCollisionDisabled && !_inCollisionWithBullet && other is HunterBullet bullet && bullet != _lastBulletCollided) { _inCollisionWithBullet = true; if (bullet.IsCollisionEnabled) //When bullet is falling, ignore collision { _lastBulletCollided = bullet; SoundManager.Instance.PlayFx(6); CoroutineManager.StartCoroutine(CollisionWithHunterBulletRoutine(bullet), this); } } if (!_stork.IsCollisionDisabled && !_inCollisionWithTornado && other is TornadoGameObject tornado && tornado != _lastTornadoCollided) { _inCollisionWithTornado = true; _lastTornadoCollided = tornado; CoroutineManager.StartCoroutine(CollisionWithTornadoRoutine(tornado), this); } }