static public Vector3 GetClosestPointOnBoundary(Moba_Camera_Boundary boundary, Vector3 point)
    {
        Vector3 pointOnBoundary = point;

        // Find the closest point on the boundary depending on type of boundary
        if (boundary.type == BoundaryType.cube)
        {
            BoxCollider boxCollider = boundary.GetComponent <BoxCollider>();

            pointOnBoundary = getClosestPointOnSurfaceBox(boxCollider, point);
        }
        else if (boundary.type == BoundaryType.sphere)
        {
            SphereCollider sphereCollider = boundary.GetComponent <SphereCollider>();

            Vector3 center = boundary.transform.position + sphereCollider.center;
            float   radius = sphereCollider.radius;

            Vector3 centerToPosition = point - center;

            // Get point on surface of the sphere
            pointOnBoundary = center + (centerToPosition.normalized * radius);
        }

        return(pointOnBoundary);
    }
    public static Vector3 GetClosestPointOnBoundary(Moba_Camera_Boundary boundary, Vector3 point)
    {
        Vector3 result = point;

        if (boundary.type == Moba_Camera_Boundaries.BoundaryType.cube)
        {
            BoxCollider component = boundary.GetComponent <BoxCollider>();
            result = Moba_Camera_Boundaries.getClosestPointOnSurfaceBox(component, point);
        }
        else if (boundary.type == Moba_Camera_Boundaries.BoundaryType.sphere)
        {
            SphereCollider component2 = boundary.GetComponent <SphereCollider>();
            Vector3        vector     = boundary.transform.position + component2.center;
            float          radius     = component2.radius;
            result = vector + (point - vector).normalized * radius;
        }
        return(result);
    }
Exemplo n.º 3
0
    public static Vector3 GetClosestPointOnBoundary(Moba_Camera_Boundary boundary, Vector3 point)
    {
        Vector3 vector = point;

        if (boundary.type == BoundaryType.cube)
        {
            return(getClosestPointOnSurfaceBox(boundary.GetComponent <BoxCollider>(), point));
        }
        if (boundary.type == BoundaryType.sphere)
        {
            SphereCollider component = boundary.GetComponent <SphereCollider>();
            Vector3        vector2   = boundary.transform.position + component.center;
            float          radius    = component.radius;
            Vector3        vector3   = point - vector2;
            vector = vector2 + ((Vector3)(vector3.normalized * radius));
        }
        return(vector);
    }
    public static Moba_Camera_Boundary GetClosestBoundary(Vector3 point)
    {
        Moba_Camera_Boundary result = null;
        float num = 999999f;

        ListView <Moba_Camera_Boundary> .Enumerator enumerator = Moba_Camera_Boundaries.cube_boundaries.GetEnumerator();
        while (enumerator.MoveNext())
        {
            Moba_Camera_Boundary current = enumerator.get_Current();
            if (!(current == null))
            {
                if (current.isActive)
                {
                    BoxCollider component = current.GetComponent <BoxCollider>();
                    Vector3     closestPointOnSurfaceBox = Moba_Camera_Boundaries.getClosestPointOnSurfaceBox(component, point);
                    float       magnitude = (point - closestPointOnSurfaceBox).magnitude;
                    if (magnitude < num)
                    {
                        result = current;
                        num    = magnitude;
                    }
                }
            }
        }
        ListView <Moba_Camera_Boundary> .Enumerator enumerator2 = Moba_Camera_Boundaries.sphere_boundaries.GetEnumerator();
        while (enumerator2.MoveNext())
        {
            Moba_Camera_Boundary current2 = enumerator2.get_Current();
            if (current2.isActive)
            {
                SphereCollider component2 = current2.GetComponent <SphereCollider>();
                Vector3        vector     = current2.transform.position + component2.center;
                float          radius     = component2.radius;
                Vector3        b          = vector + (point - vector).normalized * radius;
                float          magnitude2 = (point - b).magnitude;
                if (magnitude2 < num)
                {
                    result = current2;
                    num    = magnitude2;
                }
            }
        }
        return(result);
    }
Exemplo n.º 5
0
    public static Moba_Camera_Boundary GetClosestBoundary(Vector3 point)
    {
        Moba_Camera_Boundary boundary = null;
        float num = 999999f;

        ListView <Moba_Camera_Boundary> .Enumerator enumerator = cube_boundaries.GetEnumerator();
        while (enumerator.MoveNext())
        {
            Moba_Camera_Boundary current = enumerator.Current;
            if ((current != null) && current.isActive)
            {
                Vector3 vector    = getClosestPointOnSurfaceBox(current.GetComponent <BoxCollider>(), point);
                Vector3 vector5   = point - vector;
                float   magnitude = vector5.magnitude;
                if (magnitude < num)
                {
                    boundary = current;
                    num      = magnitude;
                }
            }
        }
        ListView <Moba_Camera_Boundary> .Enumerator enumerator2 = sphere_boundaries.GetEnumerator();
        while (enumerator2.MoveNext())
        {
            Moba_Camera_Boundary boundary3 = enumerator2.Current;
            if (boundary3.isActive)
            {
                SphereCollider component = boundary3.GetComponent <SphereCollider>();
                Vector3        vector2   = boundary3.transform.position + component.center;
                float          radius    = component.radius;
                Vector3        vector3   = point - vector2;
                Vector3        vector4   = vector2 + ((Vector3)(vector3.normalized * radius));
                Vector3        vector6   = point - vector4;
                float          num4      = vector6.magnitude;
                if (num4 < num)
                {
                    boundary = boundary3;
                    num      = num4;
                }
            }
        }
        return(boundary);
    }
Exemplo n.º 6
0
    public static bool isPointInBoundary(Vector3 point)
    {
        bool flag = false;

        ListView <Moba_Camera_Boundary> .Enumerator enumerator = cube_boundaries.GetEnumerator();
        while (enumerator.MoveNext())
        {
            Moba_Camera_Boundary current = enumerator.Current;
            if (current.isActive)
            {
                BoxCollider component = current.GetComponent <BoxCollider>();
                if (component != null)
                {
                    bool flag2;
                    calBoxRelations(component, point, false, out flag2);
                    if (flag2)
                    {
                        flag = true;
                    }
                }
            }
        }
        ListView <Moba_Camera_Boundary> .Enumerator enumerator2 = sphere_boundaries.GetEnumerator();
        while (enumerator2.MoveNext())
        {
            Moba_Camera_Boundary boundary2 = enumerator2.Current;
            if (boundary2.isActive)
            {
                SphereCollider collider2 = boundary2.GetComponent <SphereCollider>();
                if (collider2 != null)
                {
                    Vector3 vector = (boundary2.transform.position + collider2.center) - point;
                    if (vector.magnitude < collider2.radius)
                    {
                        flag = true;
                    }
                }
            }
        }
        return(flag);
    }
    public static bool isPointInBoundary(Vector3 point)
    {
        bool result = false;

        ListView <Moba_Camera_Boundary> .Enumerator enumerator = Moba_Camera_Boundaries.cube_boundaries.GetEnumerator();
        while (enumerator.MoveNext())
        {
            Moba_Camera_Boundary current = enumerator.get_Current();
            if (current.isActive)
            {
                BoxCollider component = current.GetComponent <BoxCollider>();
                if (!(component == null))
                {
                    bool flag;
                    Moba_Camera_Boundaries.calBoxRelations(component, point, false, out flag);
                    if (flag)
                    {
                        result = true;
                    }
                }
            }
        }
        ListView <Moba_Camera_Boundary> .Enumerator enumerator2 = Moba_Camera_Boundaries.sphere_boundaries.GetEnumerator();
        while (enumerator2.MoveNext())
        {
            Moba_Camera_Boundary current2 = enumerator2.get_Current();
            if (current2.isActive)
            {
                SphereCollider component2 = current2.GetComponent <SphereCollider>();
                if (!(component2 == null))
                {
                    if ((current2.transform.position + component2.center - point).magnitude < component2.radius)
                    {
                        result = true;
                    }
                }
            }
        }
        return(result);
    }
    public static Vector3 GetClosestPointOnBoundary(Moba_Camera_Boundary boundary, Vector3 point)
    {
        Vector3 pointOnBoundary = point;

        // Find the closest point on the boundary depending on type of boundary
        if(boundary.type == BoundaryType.cube) {
            BoxCollider boxCollider = boundary.GetComponent<BoxCollider>();

            pointOnBoundary = getClosestPointOnSurfaceBox(boxCollider, point);
        }
        else if(boundary.type == BoundaryType.sphere) {
            SphereCollider sphereCollider = boundary.GetComponent<SphereCollider>();

            Vector3 center 	= boundary.transform.position + sphereCollider.center;
            float radius 	= sphereCollider.radius;

            Vector3 centerToPosition = point - center;

            // Get point on surface of the sphere
            pointOnBoundary = center + (centerToPosition.normalized * radius);
        }

        return 	pointOnBoundary;
    }