Ejemplo n.º 1
0
    public void UpdateCameraPreview(ref Vector3 cameraPosition, ref float cameraOrtoSize)
    {
        if (this.m_done)
        {
            return;
        }
        if (GuiManager.GetPointer().down)
        {
            this.m_fastPreviewMultiplier = 6;
        }
        Vector2 a = cameraPosition;

        this.m_timer += Time.deltaTime * (float)this.m_fastPreviewMultiplier;
        float num  = (a - new Vector2(this.m_controlPoints[this.m_currentControlPointIndex + 1].position.x, this.m_controlPoints[this.m_currentControlPointIndex + 1].position.y)).magnitude;
        float num2 = Mathf.Abs(cameraOrtoSize - this.m_controlPoints[this.m_currentControlPointIndex + 1].zoom);

        if (this.m_timer > this.m_animationTime / (float)(this.m_controlPoints.Count - 3))
        {
            this.m_timer = this.m_animationTime / (float)(this.m_controlPoints.Count - 3);
            num          = 0f;
            num2         = 0f;
        }
        if (num < 0.5f && num2 < 0.5f)
        {
            this.m_currentControlPointIndex++;
            this.m_timer = 0f;
            if (this.m_currentControlPointIndex == this.m_controlPoints.Count - 2)
            {
                this.m_done = true;
                return;
            }
        }
        float i;

        switch (this.m_easing)
        {
        case CameraPreview.EasingAnimation.EasingIn:
            i = MathsUtil.EasingInQuad(this.m_timer, 0f, 1f, this.m_animationTime / (float)(this.m_controlPoints.Count - 3));
            break;

        case CameraPreview.EasingAnimation.EasingOut:
            i = MathsUtil.EasingOutQuad(this.m_timer, 0f, 1f, this.m_animationTime / (float)(this.m_controlPoints.Count - 3));
            break;

        case CameraPreview.EasingAnimation.EasingInOut:
            i = MathsUtil.EaseInOutQuad(this.m_timer, 0f, 1f, this.m_animationTime / (float)(this.m_controlPoints.Count - 3));
            break;

        default:
            i = this.m_timer / (this.m_animationTime / (float)(this.m_controlPoints.Count - 3));
            break;
        }
        float x    = MathsUtil.CatmullRomInterpolate(this.m_controlPoints[this.m_currentControlPointIndex - 1].position.x, this.m_controlPoints[this.m_currentControlPointIndex].position.x, this.m_controlPoints[this.m_currentControlPointIndex + 1].position.x, this.m_controlPoints[this.m_currentControlPointIndex + 2].position.x, i);
        float y    = MathsUtil.CatmullRomInterpolate(this.m_controlPoints[this.m_currentControlPointIndex - 1].position.y, this.m_controlPoints[this.m_currentControlPointIndex].position.y, this.m_controlPoints[this.m_currentControlPointIndex + 1].position.y, this.m_controlPoints[this.m_currentControlPointIndex + 2].position.y, i);
        float num3 = MathsUtil.CatmullRomInterpolate(this.m_controlPoints[this.m_currentControlPointIndex - 1].zoom, this.m_controlPoints[this.m_currentControlPointIndex].zoom, this.m_controlPoints[this.m_currentControlPointIndex + 1].zoom, this.m_controlPoints[this.m_currentControlPointIndex + 2].zoom, i);

        cameraPosition = new Vector3(x, y, cameraPosition.z);
        cameraOrtoSize = num3;
    }
Ejemplo n.º 2
0
    public static Vector3 PositionOnSpline(List <Vector3> controlPoints, float t)
    {
        int     count = controlPoints.Count;
        int     num   = Mathf.FloorToInt(t * (float)(count - 1));
        Vector3 a     = controlPoints[Mathf.Clamp(num - 1, 0, count - 1)];
        Vector3 b     = controlPoints[Mathf.Clamp(num, 0, count - 1)];
        Vector3 c     = controlPoints[Mathf.Clamp(num + 1, 0, count - 1)];
        Vector3 d     = controlPoints[Mathf.Clamp(num + 2, 0, count - 1)];
        float   i     = t * (float)(count - 1) - (float)num;

        return(MathsUtil.CatmullRomInterpolate(a, b, c, d, i));
    }
Ejemplo n.º 3
0
 public static Vector3 CatmullRomInterpolate(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float i)
 {
     return(new Vector3(MathsUtil.CatmullRomInterpolate(a.x, b.x, c.x, d.x, i), MathsUtil.CatmullRomInterpolate(a.y, b.y, c.y, d.y, i), MathsUtil.CatmullRomInterpolate(a.z, b.z, c.z, d.z, i)));
 }