Пример #1
0
        private IEnumerator CollisionWithHunterBulletRoutine(HunterBullet bullet)
        {
            //Shake Camera
            MyGame.ThisInstance.Camera.shakeDuration = 500;

            LocalEvents.Instance.Raise(new LevelLocalEvent(_stork, bullet.Shooter, _level,
                                                           LevelLocalEvent.EventType.HUNTER_HIT_PLAYER));

            LocalEvents.Instance.Raise(new StorkLocalEvent(_stork, bullet.Shooter,
                                                           StorkLocalEvent.Event.STORK_HIT_BY_HUNTER));

            //Drop a pizza
            CoroutineManager.StartCoroutine(DropPizzaRoutine(_stork.Pos - _stork.Forward * 40f, -1), this);

            yield return(new WaitForMilliSeconds(1000));

            _inCollisionWithBullet = false;

            while (bullet.Enabled)
            {
                yield return(null);
            }

            _lastBulletCollided = null;
        }
Пример #2
0
        public HunterBulletManager(Level pLevel) : base(false)
        {
            _level       = pLevel;
            _bulletsPool = new HunterBullet[10];

            for (int i = 0; i < _bulletsPool.Length; i++)
            {
                var bullet = new HunterBullet();
                _level.AddChild(bullet);
                bullet.SetActive(false);

                _bulletsPool[i] = bullet;
            }

            CoroutineManager.StartCoroutine(WaitForPlayerData(), this);
        }
Пример #3
0
 public void DespawnBullet(HunterBullet bullet)
 {
     bullet.SetActive(false);
     bullet.Shooter = null;
 }
Пример #4
0
        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);
            }
        }