Ejemplo n.º 1
0
    public void ChangeCamera()
    {
        target = carCamera.playerCar;

        if (!target)
        {
            return;
        }

        cameraChangeCount++;
        if (cameraChangeCount >= 5)
        {
            cameraChangeCount = 0;
        }

        if (target.GetComponent <RCCCarCameraConfig>())
        {
            dist               = target.GetComponent <RCCCarCameraConfig>().distance;
            height             = target.GetComponent <RCCCarCameraConfig>().height;
            carCamera.distance = dist;
            carCamera.height   = height;
        }

        if (useOrbitCamera)
        {
            orbitScript.target   = target.transform;
            orbitScript.distance = dist;
        }

        if (target.GetComponentInChildren <RCCCockpitCamera>())
        {
            cockpitCamera = target.GetComponentInChildren <RCCCockpitCamera>();
        }
        if (target.GetComponentInChildren <RCCWheelCamera>())
        {
            wheelCamera = target.GetComponentInChildren <RCCWheelCamera>();
        }

        switch (cameraChangeCount)
        {
        case 0:
            if (useFixedCamera)
            {
                if (GameObject.FindObjectOfType <RCCMainFixedCam>())
                {
                    GameObject.FindObjectOfType <RCCMainFixedCam>().canTrackNow = false;
                }
            }
            carCamera.enabled   = true;
            orbitScript.enabled = false;
            carCamera.transform.SetParent(null);
            break;

        case 1:
            if (!useOrbitCamera)
            {
                ChangeCamera();
                break;
            }
            orbitScript.enabled = true;
            carCamera.enabled   = false;
            carCamera.transform.SetParent(null);
            break;

        case 2:
            if (!cockpitCamera)
            {
                ChangeCamera();
                break;
            }
            orbitScript.enabled = false;
            carCamera.enabled   = false;
            carCamera.transform.SetParent(cockpitCamera.transform);
            carCamera.transform.localPosition             = Vector3.zero;
            carCamera.transform.localRotation             = Quaternion.identity;
            carCamera.GetComponent <Camera>().fieldOfView = 60;
            break;

        case 3:
            if (!wheelCamera)
            {
                ChangeCamera();
                break;
            }
            orbitScript.enabled = false;
            carCamera.enabled   = false;
            carCamera.transform.SetParent(wheelCamera.transform);
            carCamera.transform.localPosition             = Vector3.zero;
            carCamera.transform.localRotation             = Quaternion.identity;
            carCamera.GetComponent <Camera>().fieldOfView = 60;
            break;

        case 4:
            if (!useFixedCamera)
            {
                ChangeCamera();
                break;
            }
            orbitScript.enabled = false;
            carCamera.enabled   = false;
            carCamera.transform.SetParent(null);
            GameObject.FindObjectOfType <RCCMainFixedCam>().mainCamera  = GetComponent <Camera>();
            GameObject.FindObjectOfType <RCCMainFixedCam>().player      = target;
            GameObject.FindObjectOfType <RCCMainFixedCam>().canTrackNow = true;
            break;
        }
    }
Ejemplo n.º 2
0
    public void ChangeCamera()
    {
        if (!target)
        {
            return;
        }

        cameraChangeCount++;
        if (cameraChangeCount >= 5)
        {
            cameraChangeCount = 0;
        }

        if (target.GetComponent <RCCCarCameraConfig>())
        {
            dist               = target.GetComponent <RCCCarCameraConfig>().distance;
            height             = target.GetComponent <RCCCarCameraConfig>().height;
            carCamera.distance = dist;
            carCamera.height   = height;
        }

        if (useOrbitCamera)
        {
            orbitScript.target   = target.transform;
            orbitScript.distance = dist;
        }

        if (target.GetComponentInChildren <RCCCockpitCamera>())
        {
            cockpitCamera = target.GetComponentInChildren <RCCCockpitCamera>();
        }
        if (target.GetComponentInChildren <RCCWheelCamera>())
        {
            wheelCamera = target.GetComponentInChildren <RCCWheelCamera>();
        }

        switch (cameraChangeCount)
        {
        case 0:
            orbitScript.enabled        = false;
            carCamera.enabled          = true;
            carCamera.transform.parent = null;
            break;

        case 1:
            if (!useOrbitCamera)
            {
                ChangeCamera();
                break;
            }
            orbitScript.enabled        = true;
            carCamera.enabled          = false;
            carCamera.transform.parent = null;
            break;

        case 2:
            if (!useFixedCamera)
            {
                ChangeCamera();
                break;
            }
            orbitScript.enabled        = false;
            carCamera.enabled          = false;
            carCamera.transform.parent = null;
            break;

        case 3:
            orbitScript.enabled        = false;
            carCamera.enabled          = false;
            carCamera.transform.parent = target;
            if (!cockpitCamera)
            {
                ChangeCamera();
                break;
            }
            carCamera.transform.localPosition             = cockpitCamera.transform.localPosition;
            carCamera.transform.localRotation             = cockpitCamera.transform.localRotation;
            carCamera.GetComponent <Camera>().fieldOfView = 60;
            break;

        case 4:
            orbitScript.enabled        = false;
            carCamera.enabled          = false;
            carCamera.transform.parent = target;
            if (!wheelCamera)
            {
                ChangeCamera();
                break;
            }
            carCamera.transform.localPosition             = wheelCamera.transform.localPosition;
            carCamera.transform.localRotation             = wheelCamera.transform.localRotation;
            carCamera.GetComponent <Camera>().fieldOfView = 60;
            break;

        case 5:
            orbitScript.enabled        = false;
            carCamera.enabled          = false;
            carCamera.transform.parent = null;
            break;
        }
    }
Ejemplo n.º 3
0
    public void ChangeCamera()
    {
        cameraChangeCount++;
        if (cameraChangeCount == 6)
        {
            cameraChangeCount = 0;
        }

        if (!target)
        {
            return;
        }

        carCamera.playerCar = target.transform;

        dist   = target.GetComponent <RCCCarCameraConfig>().distance;
        height = target.GetComponent <RCCCarCameraConfig>().height;

        carCamera.distance = dist;
        carCamera.height   = height;

        orbitScript.target   = target.transform;
        orbitScript.distance = dist;

        cockpitCamera = target.GetComponentInChildren <RCCCockpit_Camera>();
        wheelCamera   = target.GetComponentInChildren <RCCWheel_Camera>();

        if (fixedCamScript)
        {
            fixedCamScript.player = target.transform;
        }

        switch (cameraChangeCount)
        {
        case 0:
            orbitScript.enabled        = false;
            carCamera.enabled          = true;
            carCamera.transform.parent = null;
            if (fixedCamScript)
            {
                fixedCamScript.canTrackNow = false;
            }
            break;

        case 1:
            orbitScript.enabled        = true;
            carCamera.enabled          = false;
            carCamera.transform.parent = null;
            if (fixedCamScript)
            {
                fixedCamScript.canTrackNow = false;
            }
            break;

        case 2:
            orbitScript.enabled        = false;
            carCamera.enabled          = false;
            carCamera.transform.parent = null;
            if (fixedCamScript)
            {
                fixedCamScript.canTrackNow = false;
            }
            break;

        case 3:
            orbitScript.enabled                           = false;
            carCamera.enabled                             = false;
            carCamera.transform.parent                    = target.transform;
            carCamera.transform.localPosition             = cockpitCamera.transform.localPosition;
            carCamera.transform.localRotation             = cockpitCamera.transform.localRotation;
            carCamera.GetComponent <Camera>().fieldOfView = 60;
            if (fixedCamScript)
            {
                fixedCamScript.canTrackNow = false;
            }
            break;

        case 4:
            orbitScript.enabled                           = false;
            carCamera.enabled                             = false;
            carCamera.transform.parent                    = target.transform;
            carCamera.transform.localPosition             = wheelCamera.transform.localPosition;
            carCamera.transform.localRotation             = wheelCamera.transform.localRotation;
            carCamera.GetComponent <Camera>().fieldOfView = 60;
            if (fixedCamScript)
            {
                fixedCamScript.canTrackNow = false;
            }
            break;

        case 5:
            orbitScript.enabled        = false;
            carCamera.enabled          = false;
            carCamera.transform.parent = null;
            if (fixedCamScript)
            {
                fixedCamScript.canTrackNow = true;
            }
            break;
        }
    }