private TlLine GetVerticalLine(bool bDown, SIntPos2 pos) { if (bDown) { pos.y--; } return(GetLine(ELineDir.eLdVertical, pos.x, pos.y)); }
private TlLine GetHorizontalLine(bool bLeft, SIntPos2 pos) { if (bLeft) { pos.x--; } return(GetLine(ELineDir.eLdHorizontal, pos.x, pos.y)); }
private void DrawLine() { int uLineLength; if (fSize < 0) { Vector3 pos; if (eLineDir == ELineDir.eLdHorizontal) { pos = new Vector3(fMoveStartPos + fSize, orgPos.y); } else { pos = new Vector3(orgPos.x, fMoveStartPos + fSize); } this.transform.localPosition = pos; if (f_bIsEnd) { nextPos = curPos; uLineLength = (int)(fMoveStartPos - fOrgPos); } else { uLineLength = (int)(-fSize); } } else { if (f_bIsEnd) { nextPos = curPos; if (eLineDir == ELineDir.eLdHorizontal) { nextPos.x++; } else { nextPos.y++; } uLineLength = (int)(fOrgPos + MAX_SIZE - fMoveStartPos); } else { uLineLength = (int)fSize; } } if (eLineDir == ELineDir.eLdHorizontal) { uiSprite.width = uLineLength; } else { uiSprite.height = uLineLength; } }
public void Init(ELineDir _eLineDir, Vector3 vec3Pos, SIntPos2 pos) { eLineDir = _eLineDir; curPos = pos; if (eLineDir == ELineDir.eLdHorizontal) { uiSprite.pivot = UIWidget.Pivot.Left; uiSprite.height = LINE_WIDTH; } else { uiSprite.pivot = UIWidget.Pivot.Bottom; uiSprite.width = LINE_WIDTH; } orgPos = vec3Pos; this.transform.localPosition = vec3Pos; this.gameObject.SetActive(false); }
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); } }