예제 #1
0
    void DrawRope()
    {
        if (!straightLine)
        {
            var lineRendererXPos = Mathf.Round(lineRenderer.GetPosition(precision - 1).x);
            var grapplePointXPos = Mathf.Round(grapple.GetGrapplePoint().x);

            var lineRendererYPos = Mathf.Round(lineRenderer.GetPosition(precision - 1).y);
            var grapplePointYPos = Mathf.Round(grapple.GetGrapplePoint().y);

            if (lineRendererXPos == grapplePointXPos && lineRendererYPos == grapplePointYPos)
            {
                straightLine = true;
            }
            else
            {
                DrawRopeWaves();
            }
        }
        else
        {
            if (!isGrappling)
            {
                isGrappling = true;
            }

            if (waveSize > 0)
            {
                waveSize -= Time.deltaTime * straightenLineSpeed;
                DrawRopeWaves();
            }
            else
            {
                waveSize = 0;

                if (lineRenderer.positionCount != 2)
                {
                    lineRenderer.positionCount = 2;
                }

                DrawRopeNoWaves();
            }
        }
    }