Example #1
0
    private void DrawLine()
    {
        float X = UICamera.lastEventPosition.x - vec2LastPos.x;
        float Y = UICamera.lastEventPosition.y - vec2LastPos.y;

        if (X == 0 && Y == 0)
        {
            return;
        }
        if (lastLine == null)
        {
            float fPos;
            if (Mathf.Abs(X) > Mathf.Abs(Y))
            {
                lastLine = GetLine(ELineDir.eLdHorizontal);
                fPos     = vec2LastPos.x - Screen.width / 2;
            }
            else
            {
                lastLine = GetLine(ELineDir.eLdVertical);
                fPos     = vec2LastPos.y - Screen.height / 2;
            }
            lastLine.InitMoveStartPos(fPos);
        }
        float fDist;

        if (lastLine.f_eLineDir == ELineDir.eLdHorizontal)
        {
            fDist = X;
        }
        else
        {
            fDist = Y;
        }
        lastLine.Move(fDist);
        if (lastLine.f_bIsEnd)
        {
            SIntPos2 nextPos = lastLine.f_nextPos;
            TlLine   nextLine;
            if (Mathf.Abs(X) > Mathf.Abs(Y))
            {
                nextLine = GetHorizontalLine(X < 0, nextPos);
                fDist    = X;
                if (nextLine == null)
                {
                    nextLine = GetVerticalLine(Y < 0, nextPos);
                    fDist    = Y;
                }
            }
            else
            {
                nextLine = GetVerticalLine(Y < 0, nextPos);
                fDist    = Y;
                if (nextLine == null)
                {
                    nextLine = GetHorizontalLine(X < 0, nextPos);
                    fDist    = X;
                }
            }
            if (nextLine != null)
            {
                nextLine.InitMoveStartPos(fDist < 0);
                lastLine = nextLine;
            }
            lastLine.Move(fDist);
        }
    }