Exemplo n.º 1
0
        public void UpdateTargetPosition(Transform targetTransform, Vector3 targetLocalPosition, float[] speedMultipliers, float[] pointsRandomness)
        {
            this.bezierPoints[0] = base.transform.position;
            float   speed = speedMultipliers[2] * this.smoothingSpeed;
            Vector3 from  = targetTransform.InverseTransformPoint(base.transform.position);

            this.endLocalPosition = this.MovePoint(this.endLocalPosition, from, targetLocalPosition, speed, pointsRandomness[2]);
            this.bezierPoints[2]  = targetTransform.TransformPoint(this.endLocalPosition);
            Vector3 to = Vector3.Lerp(base.transform.position, this.bezierPoints[2], 0.5f);

            this.bezierPoints[1]             = this.MovePoint(this.bezierPoints[1], base.transform.position, to, speedMultipliers[1] * this.smoothingSpeed, pointsRandomness[1]);
            this.nearBlob.transform.position = this.bezierPoints[0];
            this.farBlob.transform.position  = this.bezierPoints[2] + ((this.CachedCamera.transform.position - this.bezierPoints[2]).normalized * this.offsetToCamera);
            Vector3 lhs        = this.bezierPoints[2] - this.bezierPoints[0];
            float   magnitude  = lhs.magnitude;
            Vector3 normalized = Vector3.Cross(lhs, this.CachedCamera.transform.forward).normalized;
            float   num4       = magnitude / (this.curveLength * this.curvesCount);
            int     count      = 1 + Mathf.CeilToInt(magnitude / this.verticesSpacing);
            int     index      = 0;

            while (index < this.rays.Length)
            {
                this.rays[index].SetVertexCount(count);
                int num7 = 0;
                while (true)
                {
                    if (num7 >= count)
                    {
                        Vector2 mainTextureScale = this.rays[index].sharedMaterial.mainTextureScale;
                        mainTextureScale.x = magnitude / this.textureTilings[index];
                        this.rays[index].sharedMaterial.mainTextureScale = mainTextureScale;
                        index++;
                        break;
                    }
                    float   t       = ((float)num7) / ((float)(count - 1));
                    Vector3 vector7 = Bezier.PointOnCurve(t, this.bezierPoints[0], this.bezierPoints[1], this.bezierPoints[2]);
                    float   time    = ((t * num4) + ((this.textureScrollDirection * this.curveSpeed) * Time.time)) % 1f;
                    Vector3 vector8 = normalized * this.curve.Evaluate(time);
                    this.rays[index].SetPosition(num7, vector7 + vector8);
                    num7++;
                }
            }
        }
Exemplo n.º 2
0
        private static void UpdateCamera(float dt, TransitionCameraNode cameraNode)
        {
            TransitionCameraComponent    transitionCamera    = cameraNode.transitionCamera;
            CameraTransformDataComponent cameraTransformData = cameraNode.cameraTransformData;

            if (transitionCamera.TotalDistance == 0f)
            {
                transitionCamera.TransitionComplete = true;
            }
            else if (transitionCamera.Speed < 0f)
            {
                transitionCamera.TransitionComplete = true;
            }
            else
            {
                if ((transitionCamera.Distance > (0.5f * transitionCamera.TotalDistance)) && (transitionCamera.Acceleration > 0f))
                {
                    transitionCamera.Acceleration = -transitionCamera.Acceleration;
                    transitionCamera.AngleValuesX.ReverseAcceleration();
                    transitionCamera.AngleValuesY.ReverseAcceleration();
                }
                float num = transitionCamera.Acceleration * dt;
                transitionCamera.Distance += (transitionCamera.Speed + (0.5f * num)) * dt;
                transitionCamera.Speed    += num;
                if (transitionCamera.Distance > transitionCamera.TotalDistance)
                {
                    transitionCamera.Distance = transitionCamera.TotalDistance;
                }
                TransformData data2 = new TransformData {
                    Position = Bezier.PointOnCurve(transitionCamera.Distance / transitionCamera.TotalDistance, transitionCamera.P1, transitionCamera.P2, transitionCamera.P3, transitionCamera.P4),
                    Rotation = Quaternion.Euler(cameraTransformData.Data.Rotation.eulerAngles + new Vector3(transitionCamera.AngleValuesX.Update(dt), transitionCamera.AngleValuesY.Update(dt), 0f))
                };
                cameraTransformData.Data = data2;
                if (Mathf.Abs((float)(transitionCamera.Distance - transitionCamera.TotalDistance)) < 0.01f)
                {
                    transitionCamera.TransitionComplete = true;
                }
            }
        }
Exemplo n.º 3
0
 public void Apply()
 {
     this.cameraPosition  = Bezier.PointOnCurve(this.ratio, this.point0, this.point1, this.point2, this.point3);
     this.elevationAngle  = Mathf.Atan2(this.cameraPosition.x, this.cameraPosition.y);
     this.distanceToPivot = this.cameraPosition.magnitude;
 }