Exemplo n.º 1
0
 /// <summary>
 /// Teleports the camera to a position.
 /// </summary>
 public void SnapToView(CameraView newView)
 {
     _targetView             = newView;
     _startTransform         = newView.transform;
     transform.position      = newView.transform.position;
     transform.rotation      = newView.transform.rotation;
     Camera.main.fieldOfView = newView.fov;
 }
Exemplo n.º 2
0
        public void LerpToView(CameraView newView, float newSpeed = DEFAULT_SPEED)
        {
            CameraView oldView = _targetView;

            _startFOV       = oldView.fov;
            _startTransform = oldView.transform;

            _targetView = newView;
            _moving     = true;
            _speed      = newSpeed;
            _progress   = 0f;
        }
Exemplo n.º 3
0
        void Start()
        {
            _resetDistance = WorldManager.Instance.ChunkLoadRadius *
                             0.5f * WorldManager.Instance.ChunkSize;

            GameManager.Instance.onFinishLoading.AddListener(() => {
                _currentAngle = _outsideCar;
                SnapToView(_outsideCar);
            });

            UIManager.Instance.onSwitchToMainMenu.AddListener(() => {
                LerpToView(_outsideCar);
                _doSway = true;
            });

            UIManager.Instance.onSwitchToKeySelectMenu.AddListener(() => {
                LerpToView(_driving);
                _doSway = true;
            });

            UIManager.Instance.onSwitchToSongArrangeMenu.AddListener(() => {
                LerpToView(_radio);
                _doSway = false;
            });

            UIManager.Instance.onSwitchToRiffEditor.AddListener(() => {
                LerpToView(_driving);
                _doSway = true;
            });

            UIManager.Instance.onSwitchToPlaylistMenu.AddListener(() => {
                StopLiveMode();
                LerpToView(_outsideCar);
                _doSway = true;
            });

            UIManager.Instance.onSwitchToPostPlayMenu.AddListener(() => {
                _doSway = true;
            });

            UIManager.Instance.onSwitchToLiveMode.AddListener(StartLiveMode);

            UIManager.Instance.onSwitchToPostplayMode.AddListener(StopLiveMode);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Pick a specific live camera angle.
        /// </summary>
        /// <param name="camView"></param>
        public void ChangeAngle(int camView)
        {
            _currentAngle = _liveAngles[camView];
            GetComponent <Camera>().fieldOfView = _currentAngle.fov;
            //if (Debug.isDebugBuild)
            //Debug.Log("CameraControl.ChangeAngle(): switch to view \"" + currentAngle.name +".\"");

            switch (_currentAngle.placementMode)
            {
            case CameraView.CameraPlacementMode.Fixed:
                break;

            case CameraView.CameraPlacementMode.RandomGround:
                _currentAngle.targetPos = PickRandomPosition(10f, 20f);
                break;

            case CameraView.CameraPlacementMode.RandomSky:
                _currentAngle.targetPos = PickRandomPosition(25f, 50f);
                break;
            }
        }
Exemplo n.º 5
0
        new void Awake()
        {
            base.Awake();

            // Init vars
            _transitionTimer = _liveModeTransitionFreq;
            _speed           = DEFAULT_SPEED;
            onCompleteLerp   = new CameraEvent();

            // Outside car
            _viewOutsideCar = GameObject.FindGameObjectWithTag("ViewOutsideCar").transform;
            _outsideCar     = new CameraView()
            {
                name       = "OutsideCar",
                transform  = _viewOutsideCar,
                targetPos  = _viewOutsideCar.position,
                targetRot  = _viewOutsideCar.rotation,
                fov        = DEFAULT_FOV,
                followMode = CameraView.CameraFollowMode.Static
            };

            // Driving
            _viewDriving = GameObject.FindGameObjectWithTag("ViewDriving").transform;
            _driving     = new CameraView()
            {
                name       = "Driving",
                transform  = _viewDriving,
                targetPos  = _viewDriving.position,
                targetRot  = _viewDriving.rotation,
                fov        = DEFAULT_FOV,
                followMode = CameraView.CameraFollowMode.Static
            };

            // Radio
            _viewRadio = GameObject.FindGameObjectWithTag("ViewRadio").transform;
            _radio     = new CameraView()
            {
                name       = "Radio",
                transform  = _viewRadio,
                targetPos  = _viewRadio.position,
                targetRot  = _viewRadio.rotation,
                fov        = 20f,
                followMode = CameraView.CameraFollowMode.Static
            };

            _hoodForward     = GameObject.FindGameObjectWithTag("ViewHoodForward").transform;
            _nearChase       = GameObject.FindGameObjectWithTag("ViewNearChase").transform;
            _farChase        = GameObject.FindGameObjectWithTag("ViewFarChase").transform;
            _frontRightWheel = GameObject.FindGameObjectWithTag("ViewFrontRightWheel").transform;
            _frontLeftWheel  = GameObject.FindGameObjectWithTag("ViewFrontLeftWheel").transform;
            _rearRightWheel  = GameObject.FindGameObjectWithTag("ViewRearRightWheel").transform;
            _rearLeftWheel   = GameObject.FindGameObjectWithTag("ViewRearLeftWheel").transform;

            // Init live mode angles
            _liveAngles = new List <CameraView>()
            {
                // On the hood, forwards
                new CameraView()
                {
                    name       = "HoodForward",
                    transform  = _hoodForward,
                    targetPos  = _hoodForward.position,
                    targetRot  = _hoodForward.rotation,
                    fov        = DEFAULT_FOV,
                    followMode = CameraView.CameraFollowMode.Static
                },

                // Near chase
                new CameraView()
                {
                    name          = "NearChase",
                    transform     = _nearChase,
                    targetPos     = _nearChase.position,
                    targetRot     = _nearChase.rotation,
                    fov           = DEFAULT_FOV,
                    followMode    = CameraView.CameraFollowMode.Lead,
                    placementMode = CameraView.CameraPlacementMode.Fixed,
                    lag           = 0.04f
                },

                // Far chase
                new CameraView()
                {
                    name          = "FarChase",
                    transform     = _farChase,
                    targetPos     = _farChase.position,
                    targetRot     = _farChase.rotation,
                    fov           = DEFAULT_FOV,
                    followMode    = CameraView.CameraFollowMode.Lead,
                    placementMode = CameraView.CameraPlacementMode.Fixed,
                    lag           = 0.2f
                },

                // Front right wheel
                new CameraView()
                {
                    name          = "FrontRightWheel",
                    transform     = _frontRightWheel,
                    targetPos     = _frontRightWheel.position,
                    targetRot     = _frontRightWheel.rotation,
                    fov           = DEFAULT_FOV,
                    followMode    = CameraView.CameraFollowMode.Static,
                    placementMode = CameraView.CameraPlacementMode.Fixed
                },

                // Front left wheel
                new CameraView()
                {
                    name          = "FrontLeftWheel",
                    transform     = _frontLeftWheel,
                    targetPos     = _frontLeftWheel.position,
                    targetRot     = _frontLeftWheel.rotation,
                    fov           = DEFAULT_FOV,
                    followMode    = CameraView.CameraFollowMode.Static,
                    placementMode = CameraView.CameraPlacementMode.Fixed
                },

                // Rear right wheel
                new CameraView()
                {
                    name          = "RearRightWheel",
                    transform     = _rearRightWheel,
                    targetPos     = _rearRightWheel.position,
                    targetRot     = _rearRightWheel.rotation,
                    fov           = DEFAULT_FOV,
                    followMode    = CameraView.CameraFollowMode.Static,
                    placementMode = CameraView.CameraPlacementMode.Fixed
                },

                // Rear left wheel
                new CameraView()
                {
                    name          = "RearLeftWheel",
                    transform     = _rearLeftWheel,
                    targetPos     = _rearLeftWheel.position,
                    targetRot     = _rearLeftWheel.rotation,
                    fov           = DEFAULT_FOV,
                    followMode    = CameraView.CameraFollowMode.Static,
                    placementMode = CameraView.CameraPlacementMode.Fixed
                },

                // Rear left wheel
                new CameraView()
                {
                    name          = "RearLeftWheel",
                    transform     = _rearLeftWheel,
                    targetPos     = _rearLeftWheel.position,
                    targetRot     = _rearLeftWheel.rotation,
                    fov           = DEFAULT_FOV,
                    followMode    = CameraView.CameraFollowMode.Static,
                    placementMode = CameraView.CameraPlacementMode.Fixed
                },

                // Far top
                new CameraView()
                {
                    name          = "FarTop",
                    targetPos     = PickRandomPosition(25f, 50f),
                    fov           = 60f,
                    followMode    = CameraView.CameraFollowMode.Shaky,
                    placementMode = CameraView.CameraPlacementMode.RandomSky
                },

                // Distant
                new CameraView()
                {
                    name          = "Distant",
                    targetPos     = PickRandomPosition(10f, 20f),
                    fov           = 60f,
                    followMode    = CameraView.CameraFollowMode.Shaky,
                    placementMode = CameraView.CameraPlacementMode.RandomGround
                }
            };

            foreach (CameraView angle in _liveAngles)
            {
                angle.pos = angle.targetPos;
                angle.rot = angle.targetRot;
            }
        }