Esempio n. 1
0
        public bool IsInsideViewportPoints(Vector2 startPoint, Vector2 endPoint, ISelectable selectable)
        {
            Vector2[] area     = Poly.GetDefaultQuadrilateral(startPoint, endPoint);
            Vector2   position = Camera.main.WorldToViewportPoint(selectable.Position);

            return(Poly.ContainsPoint(area, position));
        }
    /// <summary>
    /// Clamps the entire bounds of this shape to the bounds of the given shape.
    /// </summary>
    /// <param name="other">The shape to clamp to.</param>
    public void ClampShapeToShape(Poly other)
    {
        Vector2[] extents     = other.borders;
        bool      sizeChanged = false;

        for (int i = 0; i < points.Length; i++)
        {
            // If any end point is not contained in the target shape, clamp it to that shape.
            if (!other.ContainsPoint(pointsWorldSpace[i]))
            {
                Vector3 clamp  = other.ClampPointToShape(new Vector3(pointsWorldSpace[i].x, 0, pointsWorldSpace[i].y));
                Vector2 newPos = new Vector2(clamp.x, clamp.z);

                // We need to update the local space points as well!
                points[i]          -= (pointsWorldSpace[i] - newPos);
                pointsWorldSpace[i] = newPos;

                sizeChanged = true;
            }
        }

        // Center and borders may have changed.
        if (sizeChanged)
        {
            FindCenter();
            SetBorders();
        }
    }
Esempio n. 3
0
    public float AddScore(List <GameObject> TriList)
    {
        //calculate score here!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        int scoreCurrent = 0;

        foreach (GameObject ShapeRect in TriRectList)
        {
            if (Poly.ContainsPoint(TriList, ShapeRect.transform.position))
            {
                scoreCurrent += 1;
            }
        }
        return(scoreCurrent);
    }
Esempio n. 4
0
    public bool IsAffected(Vector2 c)
    {
        Vector2 delta = (a - b);

        delta.Normalize();
        delta *= 0.1f;
        Vector2 da = (a - delta), db = (b + delta);
        Vector2 range = (direction * 50);
        Vector2 d     = da + range;
        Vector2 e     = db + range;
        Vector2 f     = da - range;
        Vector2 g     = db - range;

        Vector2[] polygon = { d, f, g, e };
        return(Poly.ContainsPoint(polygon, c));
    }