コード例 #1
0
        private bool IsPointHasMinDistanceToLine(LinePlain lp, Vector2 p)
        {
            if (lp.A == 0 && lp.B == 0)
            {
                return(false);
            }

            double distance = System.Math.Abs(lp.A * p.x + lp.B * p.y + lp.C) / System.Math.Sqrt(lp.A * lp.A + lp.B * lp.B);

            return(distance >= _minDistance);
        }
コード例 #2
0
    private bool IsPointHasMinDistanceToLine(LinePlain lp, Vector2 p)
    {
        const double minDistance = 0.03;

        if (lp.A == 0 && lp.B == 0)
        {
            return(false);
        }

        double distance = Math.Abs(lp.A * p.x + lp.B * p.y + lp.C) / Math.Sqrt(lp.A * lp.A + lp.B * lp.B);

        return(distance >= minDistance);
    }
コード例 #3
0
        private void DrawPlayerLine()
        {
            Vector2 screenStart = Camera.main.WorldToScreenPoint(_start);
            Vector2 startPoint  = new Vector2(screenStart.x / Screen.width, screenStart.y / Screen.height);

            Vector2 screenEnd = Camera.main.WorldToScreenPoint(_end);
            Vector2 endPoint  = new Vector2(screenEnd.x / Screen.width, screenEnd.y / Screen.height);

            if (Vector2.Distance(startPoint, endPoint) > 0.05)
            {
                var lp = new LinePlain(startPoint, endPoint);
                if (_linesController.DrawLine(lp.GetPointsForFullScreen()))
                {
                    _playerLineDrawingSound.Play();
                    _lines.Add(lp);
                    _linesCounter.HideLast();
                }
            }
        }