Ejemplo n.º 1
0
 static CollisionInfo GetCollisionInfo(Collider a, Collider b)
 {
     //all variants of collision
     //#####################
     if (a.GetType() == typeof(Circle) && b.GetType() == typeof(Circle))
     {
         return(Collisions.CirclevsCircle(a as Circle, b as Circle));
     }
     //#####################
     if (a.GetType() == typeof(Polygon) && b.GetType() == typeof(Circle))
     {
         return(Collisions.PolygonvsCircle(a as Polygon, b as Circle));
     }
     //#####################
     if (a.GetType() == typeof(Circle) && b.GetType() == typeof(Polygon))
     {
         return(Collisions.CirclevsPolygon(a as Circle, b as Polygon));
     }
     //#####################
     if (a.GetType() == typeof(Polygon) && b.GetType() == typeof(Polygon))
     {
         return(Collisions.PolygonvsPolygon(a as Polygon, b as Polygon));
     }
     //#####################
     return(null);
 }
Ejemplo n.º 2
0
        public static void Broad_Phase(GameObject a, GameObject b)
        {
            if (a.isstatic && b.isstatic)//if gameobjects are static they cant collide
            {
                return;
            }

            if ((a.collider.CollisionMask & b.collider.CollisionMask) == 0)//mask clipping
            {
                return;
            }

            if (!Collisions.AABBvsAABB(a.collider.GetBoundingBox(), b.collider.GetBoundingBox()))//AABBs
            {
                return;
            }

            Narrow_Phase(a.collider, b.collider);
        }