Beispiel #1
0
    void PushVecocityShape()
    {
        if (select == null)
        {
            if (Input.GetMouseButtonDown(0))
            {
                ShapeObject[] shapes = ShapesCollision.OverlapPoint(mousePoint);
                if (shapes.Length <= 0)
                {
                    return;
                }

                select = shapes[0];
            }
        }
        else
        {
            mouseOffset = mousePoint - select.Position;

            text.text = mouseOffset.magnitude.ToString();
            text.transform.position = mousePoint;
            Debug.DrawLine(select.Position, mousePoint);

            if (Input.GetMouseButtonUp(0))
            {
                select.Velocity = (-mouseOffset);
                select          = null;
            }
        }
    }
Beispiel #2
0
    void DragShape()
    {
        if (select != null)
        {
            select.Position = mouseOffset + mousePoint;
            select.SetColor(Color.white);
            select.RigidbodyType = RigidbodyType.Kinmatic;
        }
        else
        {
            ShapeObject[] shapes = ShapesCollision.OverlapPoint(mousePoint);
            if (shapes.Length <= 0)
            {
                return;
            }
            if (shapes[0].RigidbodyType == RigidbodyType.Static)
            {
                return;
            }

            select      = shapes[0];
            selectType  = select.RigidbodyType;
            mouseOffset = select.Position - mousePoint;
        }
    }
Beispiel #3
0
    void OverlapCheck()
    {
        //Overlap Check
        ShapeObject[] shapes = ShapeQuadTree.OverlapRect(mousePoint, checkRegion);

        foreach (var shape in shapes)
        {
            shape.SetColor(Color.black * 0.8f);
        }

        checkAngle += Input.mouseScrollDelta.y * 5;
        ShapeObject[] overlap = ShapesCollision.OverlapRectangle(mousePoint, checkAngle, checkRegion);
        foreach (var shape in overlap)
        {
            shape.SetColor(Color.white);
        }
        text.text = overlap.Length.ToString();
        text.transform.position = new Vector3(mousePoint.x, mousePoint.y);
    }
Beispiel #4
0
    void RayCastCheck()
    {
        if (Input.GetMouseButtonDown(1))
        {
            lineOrigin = mousePoint;
        }

        Vector3 dirction = mousePoint - lineOrigin;

        ShapeObject[] shapes = ShapeQuadTree.OverlapLine(lineOrigin, dirction);

        foreach (var shape in shapes)
        {
            shape.SetColor(Color.black * 0.8f);
        }

        shapes = ShapesCollision.RayCast(lineOrigin, dirction);
        foreach (var shape in shapes)
        {
            shape.SetColor(Color.white * 0.8f);
        }
        text.text = shapes.Length.ToString();
        text.transform.position = lineOrigin;
    }