예제 #1
0
    private bool AddShape()
    {
        if (geometry is ResolvedBody)
        {
            ResolvedBody resolvedBody = (ResolvedBody)geometry;
            if (resolvedBody.shapeSetted)
            {
                return(false);
            }
            switch (ShapePositions.Count)
            {
            case 3:
                resolvedBody.SetTriangle(ShapePositions.ToArray());
                break;

            case 4:
                resolvedBody.SetRectangle(ShapePositions.ToArray());
                break;

            default:
                return(false);
            }
        }
        geometryBehaviour.InitGeometry(geometry);
        return(true);
    }
예제 #2
0
    private void Resolve()
    {
        GeometryBehaviour geometryBehaviour = GameObject.Find("/3D/Geometry").GetComponent <GeometryBehaviour>();

        if (rectangleCondition != null)
        {
            Vector2   position = new Vector2(rectangleCondition.height, rectangleCondition.width);
            Vector3[] points   = new Vector3[4];
            points[0] = new Vector3(0, position.x / 2, 0);
            points[1] = new Vector3(0, -position.x / 2, 0);
            points[2] = new Vector3(0, -position.x / 2, position.y);
            points[3] = new Vector3(0, position.x / 2, position.y);
            geometry.SetRectangle(points);
            geometryBehaviour.InitGeometry(geometry);
            geometrySetted = true;
        }
        if (triangleCondition != null)
        {
            Vector2   position = new Vector2(triangleCondition.height, triangleCondition.width);
            Vector3[] points   = new Vector3[3];
            points[0] = new Vector3(0, position.x / 2, 0);
            points[1] = new Vector3(0, -position.x / 2, 0);
            points[2] = new Vector3(0, -position.x / 2, position.y);
            geometry.SetTriangle(points);
            geometryBehaviour.InitGeometry(geometry);
            geometrySetted = true;
        }
    }