Exemplo n.º 1
0
    public static FPDebugRenderer Create(GameObject targetGameObject, FContainer container, uint color, bool shouldUpdateColliders)
    {
        if (!IS_ENABLED)
        {
            return(null);
        }

        FPDebugRenderer debugRenderer = targetGameObject.AddComponent <FPDebugRenderer>();

        debugRenderer.Init(container, color, shouldUpdateColliders);
        return(debugRenderer);
    }
    // if you override this make SURE you call base.HandleUpdate
    virtual public void HandleUpdate()
    {
        UpdatePosition();
        UpdateRotation();

        FPDebugRenderer debugRenderer = physicsComponent.gameObject.GetComponent <FPDebugRenderer>();

        if (debugRenderer != null)
        {
            debugRenderer.Update();
        }
    }
    public FPPolygonalCollider AddPolygonalCollider(Vector2[] vertices, bool withDebugView = false)
    {
        FPPolygonalCollider fp = gameObject.AddComponent <FPPolygonalCollider>();

        fp.Init(new FPPolygonalData(vertices, false));

        if (withDebugView)
        {
            FPDebugRenderer.Create(gameObject, Futile.stage, 0x00FF00, false);
        }

        return(fp);
    }
    public SphereCollider AddSphereCollider(float radius, bool withDebugView = false)
    {
        SphereCollider sc = gameObject.AddComponent <SphereCollider>();

        sc.radius = radius * FPhysics.POINTS_TO_METERS;

        if (withDebugView)
        {
            FPDebugRenderer.Create(gameObject, Futile.stage, 0x00FF00, false);
        }

        return(sc);
    }
    public BoxCollider AddBoxCollider(Vector2 size, bool withDebugView = false)
    {
        BoxCollider bc = gameObject.AddComponent <BoxCollider>();

        bc.size = new Vector3(size.x * FPhysics.POINTS_TO_METERS, size.y * FPhysics.POINTS_TO_METERS, FPhysics.DEFAULT_Z_THICKNESS);

        if (withDebugView)
        {
            FPDebugRenderer.Create(gameObject, Futile.stage, 0x00FF00, false);
        }

        return(bc);
    }