示例#1
0
    private IEnumerator moveCamera(bool doSecondaryMove = false)
    {
        var toCamPos = shrineCamPos;

        if (!doSecondaryMove)
        {
            var preventables = playerMover.GetComponents <IPreventable>();
            foreach (var preventable in preventables)
            {
                preventable.StartPrevent();
            }
        }
        else
        {
            toCamPos = lateCamPos;
            if (preCameraMoveAnimator != null)
            {
                waitingToMoveCamera = true;
                preCameraMoveAnimator.gameObject.SetActive(true);
                preCameraMoveAnimator.enabled = true;
                while (waitingToMoveCamera)
                {
                    yield return(null);
                }
            }
        }

        if (cinemachineVirtualCamera != null)
        {
            cinemachineVirtualCamera.enabled = false;
            cinemachineBrain.enabled         = false;
        }
        float timePassed = 0f;

        initialCamPos = mainCam.gameObject.transform.position;
        initialCamRot = mainCam.gameObject.transform.rotation;
        while (timePassed < camMoveTime)
        {
            mainCam.gameObject.transform.position = Vector3.Lerp(initialCamPos, toCamPos.position, timePassed / camMoveTime);
            mainCam.gameObject.transform.rotation = Quaternion.Lerp(initialCamRot, toCamPos.rotation, timePassed / camMoveTime);
            timePassed += Time.deltaTime;
            yield return(null);
        }
        mainCam.gameObject.transform.position = toCamPos.position;
        mainCam.gameObject.transform.rotation = toCamPos.rotation;
        yield return(null);

        if (lateCamPos != null)
        {
            yield return(moveCamera(true));
        }
    }