Esempio n. 1
0
        //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
        //\ 
        //\ MOVEMENT
        //\ 
        //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

        /// <summary>
        /// Dolly the Camera (Move in Z axis)
        /// </summary>
        private void _doDollyCamera()
        {
            Rect viewport_rect = _getViewportRect(_zPlaneCoordinate_float);
            Rect highAndLowTrackableObjects_rect = _getRectForAllTrackableObjects(TrackingPriority.Low);
            bool areAllHighAndLowTrackableObjectsInView_boolean = RectHelper.IsRectWithinRect(viewport_rect, highAndLowTrackableObjects_rect);
            //
            Rect currentTarget_rect = _getRectForAllTrackableObjects(_currentCameraTrackingPriority);
            bool isCurrentTargetRectWithinBoundary_boolean = RectHelper.IsRectWithinRect(_viewportBoundary_rect, currentTarget_rect);



            //
            //********************************
            //1. IF WE CAN SEE LOW+HIGH THEN ALWAYS ZOOM IN MORE
            //********************************
            if (areAllHighAndLowTrackableObjectsInView_boolean)
            {
                _doUpdateZPositionTargetValue(isCurrentTargetRectWithinBoundary_boolean, areAllHighAndLowTrackableObjectsInView_boolean, 0.05f);
                if (_currentCameraTrackingPriority == TrackingPriority.High)
                {
                    _currentCameraTrackingPriority = TrackingPriority.Low;
                }
            }
            else
            {
                //********************************
                //2. IF WE CAN'T SEE LOW+HIGH AND CANNOT ZOOM OUT MORE, THEN CHANGE FOCUS
                //TO JUST THE HIGH PRIORITY OBJECTS
                //********************************
                if (_zPosition_lerptarget.targetValue == _zPosition_lerptarget.minimum)
                {
                    if (_currentCameraTrackingPriority == TrackingPriority.Low)
                    {
                        _currentCameraTrackingPriority = TrackingPriority.High;
                    }
                }
                _doUpdateZPositionTargetValue(isCurrentTargetRectWithinBoundary_boolean, areAllHighAndLowTrackableObjectsInView_boolean, -0.05f);
            }

            //UPDATE POSITION
            _zPosition_lerptarget.lerpCurrentToTarget(1);
            transform.position = new Vector3(transform.position.x, transform.position.y, _zPosition_lerptarget.targetValue);
        }