Exemplo n.º 1
0
        void Awake()
        {
            initialZoom = cameraOffset.y;
            cam         = transform.GetComponentInChildren <Camera>();
            EnableMainCamera();

            zoomStrategy = new PerspectiveZoomStrategy(cam, cameraOffset, initialZoom);
            cam.transform.LookAt(transform.position + Vector3.up * lookAtOffset);

            // Check if CameraInfo already saved for active scene. If so, load it in. Otherwise initialize it.
            if (!PlayerStatController.instance.CameraExistsForScene(SceneManager.GetActiveScene().name))
            {
                //Set intial coords
                cam.transform.localPosition = new Vector3(0f, Mathf.Abs(cameraOffset.y), -Mathf.Abs(cameraOffset.x));
            }
            else
            {
                transform.position          = PlayerStatController.instance.GetCameraInfoForScene(SceneManager.GetActiveScene().name).GetPositionVector();
                transform.eulerAngles       = PlayerStatController.instance.GetCameraInfoForScene(SceneManager.GetActiveScene().name).GetRotationVector();
                cam.transform.localPosition = PlayerStatController.instance.GetCameraInfoForScene(SceneManager.GetActiveScene().name).GetCameraPositionVector();

                PerspectiveZoomStrategy zs = zoomStrategy as PerspectiveZoomStrategy;
                zs.currentZoomLevel = PlayerStatController.instance.GetCameraInfoForScene(SceneManager.GetActiveScene().name).GetZoomLevel();
            }
        }
Exemplo n.º 2
0
    public void SaveCameraDataForScene(string scene)
    {
        GameObject focus = GameObject.FindGameObjectWithTag("Focus");
        PerspectiveZoomStrategy zoomStrategy = (focus.GetComponent <ProfitsPerParsec.CameraController>().zoomStrategy) as PerspectiveZoomStrategy;
        //Set prev cam info
        CameraInfo prevCameraInfo = new CameraInfo(
            focus.transform.position.x,
            focus.transform.position.y,
            focus.transform.position.z,
            focus.transform.eulerAngles.x,
            focus.transform.eulerAngles.y,
            focus.transform.eulerAngles.z,
            Camera.main.transform.localPosition.x,
            Camera.main.transform.localPosition.y,
            Camera.main.transform.localPosition.z,
            zoomStrategy.currentZoomLevel
            );

        cameraList[SceneManager.GetActiveScene().name] = prevCameraInfo;
    }