Exemple #1
0
 /// <summary>
 /// 添加相机
 /// </summary>
 /// <param name="camera"></param>
 public void AddCamera(GolfCamera camera)
 {
     if (!m_vCameraDic.ContainsKey((uint)camera.Type))
     {
         m_vCameraDic.Add((uint)camera.Type, camera);
     }
 }
Exemple #2
0
    private void SwitchCamera2FlyDrive()
    {
        Vector3 ballPos   = BattleM.BallPos;
        Vector3 ringPos   = BattleM.RingPos;
        Vector3 dir       = (ringPos - ballPos).normalized;
        float   len       = (ringPos - ballPos).magnitude;
        Vector3 cameraPos = ballPos - new Vector3(dir.x * 1.5f, -1f, dir.z * 1.5f);
        Vector3 lookPos   = ballPos + dir * len / 2;

        CameraM.SetCameraPosition(GolfCameraType.Drive2Fly, cameraPos);
        CameraM.LookAt(GolfCameraType.Drive2Fly, ballTransform);
        GolfCamera          camera   = CameraM.GetCamera(GolfCameraType.Drive2Fly);
        CinemachineComposer composer = camera.VCamera.GetCinemachineComponent <CinemachineComposer>();

        if (composer == null)
        {
            composer = camera.VCamera.AddCinemachineComponent <CinemachineComposer>();
        }
        composer.m_TrackedObjectOffset = new Vector3(0, 0.3f, 0);
        composer.m_HorizontalDamping   = 5;
        composer.m_VerticalDamping     = 5;
        composer.m_SoftZoneHeight      = 0.5f;
        composer.m_SoftZoneWidth       = 0.5f;
        CameraM.SwitchCamera(GolfCameraType.Drive2Fly);
    }
    // Update is called once per frame
    void Update()
    {
        if (transitionActive)
        {
            if (currentActiveCamera != null && currentTargetCamera != null)
            {
                currentActiveCamera.transform.rotation = GolfCamera.SmoothLookAt(currentActiveCamera.transform, currentTargetCamera.Target.transform,
                                                                                 cameraRotationSpeed);

                //Move towards the target camera
                float dist = (Vector3.Distance(currentActiveCamera.transform.position, currentTargetCamera.transform.position));
                currentActiveCamera.transform.position = Vector3.MoveTowards(currentActiveCamera.transform.position,
                                                                             currentTargetCamera.transform.position,
                                                                             (cameraTransitionSpeed + (dist * cameraDistanceSpeedMultiplyer)) * Time.deltaTime);

                //Check if we are at the camera postion
                if (currentActiveCamera.transform.position == currentTargetCamera.transform.position)
                {
                    //Stop Transition
                    transitionActive    = false;
                    currentTargetCamera = currentActiveCamera = null;
                }
            }
        }
    }
Exemple #4
0
 private void DragMapMoveCamera(Vector3 dir, float moveSpeed)
 {
     if (CameraM.CurType == GolfCameraType.Sky)
     {
         dir = new Vector3(-dir.x, 0, -dir.y);
         dir.Normalize();
         GolfCamera skyCamera = CameraM.GetCamera(GolfCameraType.Sky);
         skyCamera.VCamera.transform.position += dir * moveSpeed;
     }
 }
Exemple #5
0
 private void ScaleMapMoveCamera(float axis, float scaleSpeed)
 {
     if (CameraM.CurType == GolfCameraType.Sky)
     {
         GolfCamera skyCamera = CameraM.GetCamera(GolfCameraType.Sky);
         Vector3    pos       = skyCamera.VCamera.transform.position;
         pos.y -= axis * scaleSpeed;
         skyCamera.VCamera.transform.position = pos;
     }
 }
Exemple #6
0
 public void UpdateCamera2Fly()
 {
     if (CameraM.CurType == GolfCameraType.Fly2Land)
     {
         Vector3    pos    = BattleM.BallPos;
         GolfCamera camera = CameraM.GetCamera(CameraM.CurType);
         pos = new Vector3(pos.x, camera.VCamera.transform.position.y, pos.z);
         CameraM.LookAt(GolfCameraType.Fly2Land, pos);
     }
 }
Exemple #7
0
    public void SetCameraPosition(GolfCameraType cameraType, Vector3 pos)
    {
        uint       cameraIdx = (uint)cameraType;
        GolfCamera camera    = null;

        if (m_vCameraDic.TryGetValue(cameraIdx, out camera))
        {
            camera.SetPosition(pos);
        }
    }
Exemple #8
0
    public void Follow(GolfCameraType cameraType, Transform trans)
    {
        uint       cameraIdx = (uint)cameraType;
        GolfCamera camera    = null;

        if (m_vCameraDic.TryGetValue(cameraIdx, out camera))
        {
            camera.Follow(trans);
        }
    }
Exemple #9
0
    public void LookAt(GolfCameraType cameraType, Vector3 pos)
    {
        uint       cameraIdx = (uint)cameraType;
        GolfCamera camera    = null;

        if (m_vCameraDic.TryGetValue(cameraIdx, out camera))
        {
            camera.VCamera.transform.LookAt(pos);
        }
    }
Exemple #10
0
    public void SetCameraRotation(GolfCameraType cameraType, Quaternion rot)
    {
        uint       cameraIdx = (uint)cameraType;
        GolfCamera camera    = null;

        if (m_vCameraDic.TryGetValue(cameraIdx, out camera))
        {
            camera.SetRotation(rot);
        }
    }
Exemple #11
0
    public GolfCamera GetCamera(GolfCameraType cameraType)
    {
        uint       cameraIdx = (uint)cameraType;
        GolfCamera camera    = null;

        if (m_vCameraDic.TryGetValue(cameraIdx, out camera))
        {
            return(camera);
        }
        return(null);
    }
 /// <summary>
 /// Checks if we are transitioning between two cameras
 /// </summary>
 /// <returns>If we are transitioning</returns>
 public bool IsTransitioning(GolfCamera activeCamera, GolfCamera targetCamera)
 {
     if (transitionActive)
     {
         if (activeCamera == currentActiveCamera && targetCamera == currentTargetCamera)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #13
0
    /// <summary>
    /// 切换相机
    /// </summary>
    /// <param name="cameraType"></param>
    /// <param name="canChange2Self"></param>
    public void SwitchCamera(GolfCameraType cameraType, bool canChange2Self = false)
    {
        if (!canChange2Self && CurType == cameraType)
        {
            return;
        }

        uint       cameraIdx = (uint)cameraType;
        GolfCamera camera    = null;

        if (m_vCameraDic.TryGetValue(cameraIdx, out camera))
        {
            camera.SetActive();
            CurType = cameraType;
        }
    }
 /// <summary>
 /// Initiates the transition between two cameras
 /// </summary>
 /// <param name="activeCamera">Active Camera to manipulate</param>
 /// <param name="targetCamera">Camera to move towards</param>
 public void InitiateCameraTransision(GolfCamera activeCamera, GolfCamera targetCamera)
 {
     currentActiveCamera = activeCamera;
     currentTargetCamera = targetCamera;
     transitionActive    = true;
 }