Example #1
0
        private void OpeningSequenceUpdate()
        {
            switch (_openingSequenceStage)
            {
            case eOpeningSequenceStage.autoPinch:
                float mult = (Time.time - _autoPinchStartTime) / OpeningAutoPinchTime;
                if (mult >= 1f)                         // finished auto pinch
                {
                    _cameraComponent.SetZoomDistance(1f);
                    _openingSequenceStage = eOpeningSequenceStage.none;

                    if (UIHierarchyHelper.Instance)
                    {
                        UIHierarchyHelper.Instance.ShowRegularHUD(true);                                 // we're going back to the normal HUD
                    }
                    //EventManager.instance.Raise(new IntroCompleteEvent()); // the intro sequence is over
                    PlayerController.LocalPlayerEnableNavigation();                             // normal player control

                    StartWalk(_spawnerFacingDirection);
                }
                else
                {
                    mult = Cinematic.Smooth(mult, CameraLerp.LerpSmoothing.slowFastSlow);
                    _cameraComponent.SetZoomDistance(mult);
                }
                break;

            case eOpeningSequenceStage.none:
                break;

            default: break;
            }
        }
Example #2
0
    protected void UpdateCameraBehaviors(float delatTime)
    {
        //if (Application.isPlaying) // we only want the output from the running behaviors if we're playing
        //{
        for (int running = GetOldestRunningBehaviorIndex(); running <= GetNewestRunningBehaviorIndex(); ++running)
        {
            if (_gameCamera != _runningBehaviors[running].behavior)                     // we don't tick the game camera here, as that is already ticked in the update function
            {
                _runningBehaviors[running].behavior.Update(this, delatTime);
            }

            if (!_runningBehaviors[running].HasLerpStyleBeenSet())
            {
                GameCameraBehavior olderBehavior = (GetOldestRunningBehaviorIndex() == running) ? null : _runningBehaviors[running - 1].behavior;
                _runningBehaviors[running].lerpStyle = CameraLerp.DetermineBestLerpStyle(olderBehavior, _runningBehaviors[running].behavior);
            }

            _runningBehaviors[running].behavior.GetLookAt(ref _runningBehaviorResult.lookAt);
            _runningBehaviors[running].behavior.GetRotation(ref _runningBehaviorResult.rotation);
            _runningBehaviorResult.distFromLookAt = _runningBehaviors[running].behavior.GetDistFromLookAt();

            // oldest camera is always fully blended in
            float lerp = 1f;
            if (NeedCalculateLerp(running))
            {
                lerp = Mathf.Clamp01(_runningBehaviors[running].CalculateLerpValue());
            }
            float smoothedLerp      = 1f;
            float smoothedLerpPitch = 1f;
            float smoothedLerpYaw   = 1f;
            if (NeedSmoothRunningBehavior(running))                     // not the oldest running cam and not fully blended in
            {
                smoothedLerp      = Cinematic.Smooth(lerp, _runningBehaviors[running].lerp.dialogueCameraLerpSmoothing, _runningBehaviors[running].lerp.animationCurve);
                smoothedLerpPitch = Cinematic.Smooth(lerp, _runningBehaviors[running].lerp.pitchLerpSmoothing, _runningBehaviors[running].lerp.curvePitchLerp);
                smoothedLerpYaw   = Cinematic.Smooth(lerp, _runningBehaviors[running].lerp.yawLerpSmoothing, _runningBehaviors[running].lerp.curveYawLerp);
            }
            BlendedCameraBehavior.BlendedCameraOutput.Lerp(ref _blendedResult, ref _blendedResult, ref _runningBehaviorResult,
                                                           _runningBehaviors[running].lerpStyle, smoothedLerp, smoothedLerpPitch, smoothedLerpYaw);
            _gameCameraPosition = _blendedResult.CalculatePosition();
            _gameCameraRotation = _blendedResult.rotation;
        }
        //}
        RemoveRunningBehaviors();
    }
Example #3
0
        private void ClosingSequenceUpdate()
        {
            switch (_closingSequenceStage)
            {
            case eClosingSequenceStage.autoPinch:
                float mult = (Time.time - _autoPinchStartTime) / ClosingAutoPinchTime;
                if (mult >= 1f)                         // finished auto pinch
                {
                    _cameraComponent.SetZoomDistance(0f);

                    // play the closing animation
                    GameObject         localPlayer = PlayerManager.LocalPlayerGameObject();
                    CharacterComponent charTarget  = null;
                    if (null != localPlayer)
                    {
                        charTarget = localPlayer.GetComponent <CharacterComponent>();
                        if (null != charTarget)
                        {
                            PlayStartOrEndAnimationSound(false);
                            PlaySpecialAnimation(eSpecialAnimationVariety.DungeonEnd, charTarget, false);
                        }
                    }

                    StartCoroutine(WaitForClosingSequenceEnd(charTarget));
                }
                else
                {
                    mult = Cinematic.Smooth(mult, CameraLerp.LerpSmoothing.slowFastSlow);
                    _cameraComponent.SetZoomDistance(_autoPinchStartZoom - mult * _autoPinchStartZoom);
                }
                break;

            case eClosingSequenceStage.none:
                break;

            default: break;
            }
        }
Example #4
0
    private void UpdateIdleState()
    {
        if (_resumeFollowCamera)
        {
            _resumeFollowCamera = false;
            MyFollowCamera.Instance.ResumeCameraView();
            RenderSettingsManager.Instance.ReplaceGlobalCharacterOutline(1);
        }
        else if (m_TweenID == null)
        {
            if (!m_isLerpingBackToIdlePath)  //设为idle后,首先进这里
            {
                float nearest_dist  = -1f;
                int   nearest_index = 0;

                for (int i = 0; i < waypointObjects.Length; i++)
                {
                    float dist = (transform.position - waypointObjects[i].transform.position).sqrMagnitude;

                    if (nearest_dist < 0)
                    {
                        nearest_dist = dist;
                    }
                    else
                    {
                        if (dist < nearest_dist)
                        {
                            nearest_dist  = dist;
                            nearest_index = i;
                        }
                    }
                }

                m_lerpback_starttime      = Time.realtimeSinceStartup;
                m_lerpback_index          = nearest_index;
                m_lerpback_startposition  = transform.position;
                m_lerpback_startquaterion = transform.rotation;
                Vector3 lookForward = m_lookat_locator.transform.position - waypointObjects[nearest_index].transform.position;
                lookForward.Normalize();
                m_lerpback_endquaterion   = Quaternion.LookRotation(lookForward);
                m_isLerpingBackToIdlePath = true;
                LerpBackToIdlePath(nearest_index);                  //m_isLerpingBackToIdlePath标志位设为true,m_idleTween要等lerp到一点后才会设值
            }
            else
            {
                bool lerpback_finish = false;
                if (!Mathf.Approximately(m_cameraLerpBackTime, 0.0f))
                {
                    float lerp        = Mathf.Clamp01((Time.realtimeSinceStartup - m_lerpback_starttime) / m_cameraLerpBackTime);
                    float smooth_lerp = Cinematic.Smooth(lerp, m_cameraLerpBackSmooting, m_cameraLerpBackAnimationCurve);
                    transform.position = Vector3.Lerp(m_lerpback_startposition, waypointObjects[m_lerpback_index].transform.position, smooth_lerp);
                    transform.rotation = Quaternion.Lerp(m_lerpback_startquaterion, m_lerpback_endquaterion, smooth_lerp);
                    if (Time.realtimeSinceStartup - m_lerpback_starttime >= m_cameraLerpBackTime)
                    {
                        lerpback_finish = true;
                    }
                }
                else
                {
                    lerpback_finish = true;
                }

                if (lerpback_finish)
                {
                    if (m_lerpback_index == 0)
                    {
                        StartClockWiseTween();
                    }
                    else if (m_lerpback_index == (waypointObjects.Length - 1))
                    {
                        StartCounterClockWiseTween();
                    }
                    else
                    {
                        LerpFromNearestWaypoint((object)m_lerpback_index);
                    }
                }
            }
        }
        else
        {
            if (!m_isLerpingBackToIdlePath)
            {
                transform.LookAt(m_lookat_locator.transform.position);
            }
            if (MyFollowCamera.Instance)
            {
                MyFollowCamera.Instance.isActive = true;
            }
        }
    }