Example #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;
    }
Example #2
0
            public override void Update()
            {
                this.m_timer += Time.unscaledDeltaTime;
                if (this.m_timer >= this.m_time)
                {
                    this.m_finished = true;
                }
                float num = MathsUtil.EaseInOutQuad(this.m_timer, 0f, 1f, this.m_time);

                num = 0.5f * num + 0.5f * (this.m_timer / this.m_time);
                this.m_pointer.SetPosition(Tutorial.PositionOnSpline(this.m_positions, num));
            }
Example #3
0
    private void Update()
    {
        if (this.m_contraptionAssets.Count == 0)
        {
            return;
        }
        this.m_timer += Time.deltaTime;
        this.m_resourceUnloadTimer += Time.deltaTime;
        if (this.m_resourceUnloadTimer > 600f)
        {
            this.m_resourceUnloadTimer = 0f;
            Resources.UnloadUnusedAssets();
        }
        float num  = 0.666f;
        float num2 = 8f;

        if (this.m_state == MenuContraptionManager.State.Default)
        {
            if (this.m_cameraTarget)
            {
                this.SetState(MenuContraptionManager.State.Zooming);
            }
            else
            {
                this.CreateContraption();
            }
        }
        else if (this.m_state == MenuContraptionManager.State.Zooming)
        {
            float   num3   = 4f;
            float   t      = MathsUtil.EaseInOutQuad(this.m_timer, 0f, 1f, num3);
            Vector3 vector = this.CameraTargetPosition();
            vector = num * vector + (1f - num) * this.m_defaultCameraPosition;
            this.m_camera.transform.position = Vector3.Slerp(this.m_zoomOutPosition, vector, t);
            this.m_camera.orthographicSize   = Mathf.Lerp(15f, num2, t);
            if (this.m_timer > num3)
            {
                this.SetState(MenuContraptionManager.State.Following);
            }
        }
        else if (this.m_state == MenuContraptionManager.State.ReturnToZoom)
        {
            this.m_returnTimer += Time.deltaTime;
            float   num4    = 5f;
            float   t2      = MathsUtil.EaseInOutQuad(this.m_timer, 0f, 1f, num4);
            Vector3 vector2 = this.CameraTargetPosition();
            vector2 = num * vector2 + (1f - num) * this.m_defaultCameraPosition;
            Vector3 vector3 = Vector3.Slerp(this.m_zoomOutPosition, vector2, t2);
            Vector3 a       = vector3;
            float   num5    = 1f;
            if (this.m_returnTimer < 4f)
            {
                float t3 = MathsUtil.EaseInOutQuad(this.m_returnTimer, 0f, 1f, 4f);
                a    = Vector3.Slerp(this.m_cameraStartPosition, this.m_zoomOutPosition, t3);
                num5 = MathsUtil.EaseInOutQuad(Mathf.Clamp(this.m_timer, 0f, 1f), 0f, 1f, 1f);
            }
            this.m_camera.orthographicSize   = Mathf.Lerp(15f, num2, t2);
            this.m_camera.transform.position = num5 * vector3 + (1f - num5) * a;
            if (this.m_timer > num4)
            {
                this.SetState(MenuContraptionManager.State.Following);
            }
        }
        else if (this.m_state == MenuContraptionManager.State.Following)
        {
            if (!this.m_cameraTarget)
            {
                this.SetState(MenuContraptionManager.State.Returning);
                return;
            }
            Vector3 vector4 = this.CameraTargetPosition();
            vector4 = num * vector4 + (1f - num) * this.m_defaultCameraPosition;
            this.m_camera.transform.position = vector4;
            this.m_camera.orthographicSize   = num2;
            Vector3 position  = this.m_cameraTarget.transform.position;
            Vector3 position2 = this.m_camera.transform.position;
            Vector2 vector5   = new Vector2(this.m_camera.orthographicSize * (float)Screen.width / (float)Screen.height, this.m_camera.orthographicSize);
            float   num6      = -5f + -15f * (float)Screen.width / (float)Screen.height;
            if (position.x > position2.x + vector5.x - 5f || position.x < num6 - 10f || position.y > position2.y + vector5.y - 5f || position.y < -15f)
            {
                this.m_contraptionController.StartRemoveTimer(4f);
                this.SetState(MenuContraptionManager.State.Returning);
            }
            if (this.m_timer > 30f)
            {
                this.m_contraptionController.StartRemoveTimer(4f);
                this.SetState(MenuContraptionManager.State.Returning);
            }
            if (this.m_contraption.IsMovementStopped())
            {
                this.m_contraptionController.StartRemoveTimer(4f);
                this.SetState(MenuContraptionManager.State.Returning);
            }
        }
        else if (this.m_state == MenuContraptionManager.State.Returning)
        {
            float   num7    = 4f;
            float   t4      = MathsUtil.EaseInOutQuad(this.m_timer, 0f, 1f, num7);
            float   num8    = MathsUtil.EaseInOutQuad(this.m_timer, 0f, 1f, num7 - 1f);
            Vector3 vector6 = Vector3.Slerp(this.m_cameraStartPosition, this.m_zoomOutPosition, t4);
            this.m_camera.orthographicSize = Mathf.Lerp(this.m_cameraStartSize, 15f, num8);
            Vector3 a2 = vector6;
            if (this.m_cameraTarget)
            {
                a2 = this.CameraTargetPosition();
                a2 = num * a2 + (1f - num) * this.m_defaultCameraPosition;
            }
            this.m_camera.transform.position = num8 * vector6 + (1f - num8) * a2;
            if (this.m_timer > num7 - 1f)
            {
                this.m_returnTimer = this.m_timer;
                this.SetState(MenuContraptionManager.State.ReturnToZoom);
                this.CreateContraption();
            }
        }
    }