예제 #1
0
    /// <summary>最小外接矩形の上下左右の座標(ローカル座標)を返す</summary>
    public static RectangleEndPoint minimumCircumscribedRectangleEndPoint(this EdgeCollider2D aCollider)
    {
        RectangleEndPoint tPoints = new RectangleEndPoint();

        tPoints.up    = aCollider.points[0].y;
        tPoints.down  = aCollider.points[0].y;
        tPoints.left  = aCollider.points[0].x;
        tPoints.right = aCollider.points[0].x;
        foreach (Vector2 tPoint in aCollider.points)
        {
            if (tPoint.x < tPoints.left)
            {
                tPoints.left = tPoint.x;
            }
            else if (tPoints.right < tPoint.x)
            {
                tPoints.right = tPoint.x;
            }
            if (tPoints.up < tPoint.y)
            {
                tPoints.up = tPoint.y;
            }
            else if (tPoint.y < tPoints.down)
            {
                tPoints.down = tPoint.y;
            }
        }
        return(tPoints);
    }
예제 #2
0
    /// <summary>最小外接矩形の上下左右の座標(ローカル座標)を返す</summary>
    public static RectangleEndPoint minimumCircumscribedRectangleEndPoint(this CircleCollider2D aCollider)
    {
        RectangleEndPoint tPoints = new RectangleEndPoint();

        tPoints.up    = aCollider.radius;
        tPoints.down  = -aCollider.radius;
        tPoints.left  = -aCollider.radius;
        tPoints.right = aCollider.radius;
        return(tPoints);
    }
예제 #3
0
    /// <summary>最小外接矩形の上下左右の座標(ローカル座標)を返す</summary>
    public static RectangleEndPoint minimumCircumscribedRectangleEndPoint(this BoxCollider2D aCollider)
    {
        RectangleEndPoint tPoints = new RectangleEndPoint();

        tPoints.up    = aCollider.size.y / 2f + aCollider.offset.y;
        tPoints.down  = -aCollider.size.y / 2f + aCollider.offset.y;
        tPoints.left  = -aCollider.size.x / 2f + aCollider.offset.x;
        tPoints.right = aCollider.size.x / 2f + aCollider.offset.x;
        return(tPoints);
    }