Пример #1
0
        public override void Initialize(AdvancedUtilities.Cameras.CameraController cameraController)
        {
            base.Initialize(cameraController);

            Input      = new InputValues();
            _smoothing = new InputSmoothingStatus(this);
        }
        public override void Initialize(AdvancedUtilities.Cameras.CameraController cameraController)
        {
            base.Initialize(cameraController);

            _previousUseSpecifiedSeed = UseSpecificSeed;
            _previousSeed             = Seed;
            _previousMode             = Mode;

            _random = null;
        }
Пример #3
0
        public override void Initialize(AdvancedUtilities.Cameras.CameraController cameraController)
        {
            base.Initialize(cameraController);

            IsHeadbobbing             = false;
            Forced                    = false;
            Reorienting               = false;
            _headbobReorientStartTime = -ReadjustToNormalTime;

            ReorientingLerpTransformer = new DoNothingLerpTransformer();
        }
Пример #4
0
 /// <summary>
 /// For each Camera Component that is shared between this Camera Controller and the given Camera Controller, this will
 /// copy the public fields from the given controller's components onto this controller's components.
 /// This does not replace this controller's components with the given controller's components.
 /// </summary>
 /// <param name="otherController">The controller whose component's you want to override this controller's components.</param>
 public void CopyPublicFields(AdvancedUtilities.Cameras.CameraController otherController)
 {
     foreach (var component in _components.Values)
     {
         CameraComponent otherComponent;
         if (otherController._components.TryGetValue(component.GetType(), out otherComponent))
         {
             component.CopyPublicFields(otherComponent);
         }
     }
 }
Пример #5
0
        public override void Initialize(AdvancedUtilities.Cameras.CameraController cameraController)
        {
            base.Initialize(cameraController);

            _worldSpaceOffsets = new List <Vector3>();
            _localSpaceOffsets = new List <Vector3>();

            if (Target == null)
            {
                Debug.LogWarning("There is no Target for this TargetComponent.");
            }
        }
Пример #6
0
        public override void Initialize(AdvancedUtilities.Cameras.CameraController cameraController)
        {
            base.Initialize(cameraController);
            _target = GetCameraComponent <TargetComponent>();

            _previouslyDeterminedRotation = _target.Target.rotation;
            _previousTargetState          = new VirtualTransform(_target.Target);

            _finishedAdjustment = true;
            _forceAdjustment    = false;

            FixOffsets();

            if (RotationLerpTransformer == null)
            {
                RotationLerpTransformer = new DoNothingLerpTransformer();
            }
        }
        /// <summary>
        /// Switches the active camera to the given index.
        /// </summary>
        /// <param name="index">Index in the list of cameras.</param>
        /// <param name="copyComponents">Whether or not components fields will be copied from the current camera to the next.</param>
        public void SwitchCamera(int index, bool copyComponents = false)
        {
            if (index < 0 || index > CameraControllers.Count - 1)
            {
                throw new ArgumentOutOfRangeException("The index: " + index + " is not a valid index for a Camera.");
            }

            AdvancedUtilities.Cameras.CameraController previousCameraController = CameraControllers[_currentCameraIndex];

            // Setup out new index, and the position we left off of
            _switchTransform    = new VirtualTransform(CameraTransform);
            _currentCameraIndex = index;
            _switchBeginTime    = Time.time;

            // Copy the fields before we initialize
            if (copyComponents)
            {
                CameraControllers[_currentCameraIndex].CopyPublicFields(previousCameraController);
            }

            // We want the camera to initialize, but we don't want it actually updating. Enabling and disabling will do that.
            CameraControllers[_currentCameraIndex].enabled = true;
            CameraControllers[_currentCameraIndex].enabled = false;

            // Setting up the speed after the new camera has been initialized so that we have the correct position for measurements.
            // If we're at 0 or less, then set our position to the new camera's position immediately.
            if (SwitchSpeed <= 0)
            {
                // Snap if equal or less than 0
                _switchSpeed = float.MaxValue;
                CameraControllers[_currentCameraIndex].CameraTransform.ApplyTo(CameraTransform);
            }
            // Otherwise, we set up the speed.
            else
            {
                _switchSpeed = SwitchSpeed;
                if (ConstantSwitchSpeedInit)
                {
                    _switchSpeed = Vector3.Distance(_switchTransform.Position, CameraControllers[_currentCameraIndex].CameraTransform.Position) / SwitchSpeed;
                }
            }
        }
        public override void Initialize(AdvancedUtilities.Cameras.CameraController cameraController)
        {
            base.Initialize(cameraController);

            if (Targets.Count == 0)
            {
                Debug.LogError("There is no target for this MultipleRelativeTargetComponent.");
            }

            _worldSpaceOffsets = new List <Vector3>();
            _localSpaceOffsets = new List <Vector3>();

            if (LerpTransformer == null)
            {
                LerpTransformer = new DoNothingLerpTransformer();
            }

            _switchStartTime = -SwitchSpeed;

            _previousTarget = null;
            _currentTarget  = null;
        }
Пример #9
0
        public override void Initialize(AdvancedUtilities.Cameras.CameraController cameraController)
        {
            base.Initialize(cameraController);

            if (Target == null)
            {
                Debug.LogError("There is no target for this SwitchTargetComponent.");
            }

            _worldSpaceOffsets = new List <Vector3>();
            _localSpaceOffsets = new List <Vector3>();

            if (LerpTransformer == null)
            {
                LerpTransformer = new DoNothingLerpTransformer();
            }

            _currentTarget    = Target;
            _previousPosition = Target.position + WorldSpaceOffset + Target.rotation * LocalSpaceOffset;

            _switchStartTime = -SwitchSpeed;
        }
        public override void UpdateCamera()
        {
            // This was a public variable can switch the camera.
            if (CurrentIndex != _currentCameraIndex)
            {
                SwitchCamera(CurrentIndex);
            }

            AdvancedUtilities.Cameras.CameraController cam = CameraControllers[_currentCameraIndex];

            cam.UpdateCamera();

            // Lerping, we have to calculate between positions.
            if (Time.time - _switchBeginTime < _switchSpeed)
            {
                float t  = (Time.time - _switchBeginTime) / _switchSpeed;
                float pt = PositionLerpTransformer.Process(t);
                float rt = RotationLerpTransformer.Process(t);

                var lerpVirtualTransform = new VirtualTransform();

                // Lerp position
                lerpVirtualTransform.Position = Vector3.Lerp(_switchTransform.Position, cam.CameraTransform.Position, pt);

                // Lerp rotation
                lerpVirtualTransform.Rotation = SwitchSlerpRotation ?
                                                Quaternion.Slerp(_switchTransform.Rotation, cam.CameraTransform.Rotation, rt) :
                                                Quaternion.Lerp(_switchTransform.Rotation, cam.CameraTransform.Rotation, rt);

                lerpVirtualTransform.ApplyTo(CameraTransform);
            }
            // Not Lerping, we just set the position.
            else
            {
                cam.CameraTransform.ApplyTo(CameraTransform);
            }
        }
Пример #11
0
        public override void Initialize(AdvancedUtilities.Cameras.CameraController cameraController)
        {
            base.Initialize(cameraController);

            ZoomLerpTransformer = new DoNothingLerpTransformer();
        }
Пример #12
0
 public override void Initialize(AdvancedUtilities.Cameras.CameraController cameraController)
 {
     base.Initialize(cameraController);
 }
Пример #13
0
        public override void Initialize(AdvancedUtilities.Cameras.CameraController cameraController)
        {
            base.Initialize(cameraController);

            _input = GetCameraComponent <InputComponent>();
        }
Пример #14
0
 /// <summary>
 /// Sets up this component for the given Camera Controller that it is attached to.
 /// </summary>
 /// <param name="cameraController">The camera controller that this component is attached to.</param>
 public virtual void Initialize(AdvancedUtilities.Cameras.CameraController cameraController)
 {
     _cameraController = cameraController;
 }