Example #1
0
    private void DrawHorizontalLine(int x, int y)
    {
        TlLine scrLine = CreateLine(ELineDir.eLdHorizontal, x, y);

        scrLine.gameObject.name = HORIZONTAL_LINE + "_" + x + "_" + y;
        arrDownLine[x, y]       = scrLine;
    }
Example #2
0
    private void DrawVerticalLine(int x, int y)
    {
        TlLine scrLine = CreateLine(ELineDir.eLdVertical, x, y);

        scrLine.gameObject.name = VERTICAL_LINE + "_" + x + "_" + y;
        arrRightLine[x, y]      = scrLine;
    }
Example #3
0
    private TlLine CreateLine(ELineDir eLineDir, int x, int y)
    {
        GameObject go      = CreateLine(_goPreLine);
        Vector2    vec2Pos = new Vector2(x * 50 - Screen.width / 2, y * 50 - Screen.height / 2) + vec2Offset;
        Vector3    pos     = new Vector3(vec2Pos.x, vec2Pos.y);
        TlLine     scrLine = go.GetComponent <TlLine>();

        scrLine.Init(eLineDir, pos, new SIntPos2(x, y));
        return(scrLine);
    }
Example #4
0
 void Update()
 {
     if (Input.GetMouseButton(0))
     {
         if (bMove)
         {
             DrawLine();
         }
         vec2LastPos = UICamera.lastEventPosition;
         bMove       = true;
     }
     if (Input.GetMouseButtonUp(0))
     {
         bMove    = false;
         lastLine = null;
     }
 }
Example #5
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);
        }
    }