コード例 #1
0
        private IEnumerator CollisionWithAirplaneRoutine(Airplane plane)
        {
            //_stork.InputEnabled = false;

            //Shake Camera
            MyGame.ThisInstance.Camera.shakeDuration = 500;

            LocalEvents.Instance.Raise(new StorkLocalEvent(_stork, StorkLocalEvent.Event.STORK_HIT_BY_PLANE));

            if (!_level.IsLevelEnding)
            {
                //Drop a pizza
                CoroutineManager.StartCoroutine(DropPizzaRoutine(_stork.Pos - _stork.Forward * 40f), this);
            }

            LocalEvents.Instance.Raise(new LevelLocalEvent(_stork, plane, _level,
                                                           LevelLocalEvent.EventType.PLANE_HIT_PLAYER));

            yield return(new WaitForMilliSeconds(1500));

            //_stork.InputEnabled = true;
            _inCollisionWithAirplane = false;
        }
コード例 #2
0
 void DespawnAirplane(Airplane airplane)
 {
     airplane.SetActive(false);
 }
コード例 #3
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);
            }
        }