Beispiel #1
0
        /**
         * Check if agent intersect with shape
         *
         * Agent will automatically detect which shape is used to calculate collision
         **/
        public virtual CollisionResult IntersectWithShape(ConvexShape shape)
        {
            switch (shape.ShapeId)
            {
            case ConvexShapeID.Rectangle:            //Rectangle
                ConvexRect rectShape = shape as ConvexRect;
                if (rectShape == null)
                {
                                        #if DEBUG
                    Debug.LogError("Unable to down cast ConvexShape to ConvexRect");
                                        #endif
                }
                return(ContactWithRectangle(rectShape));

            case ConvexShapeID.Circle:            //Circle
                ConvexCircle circleShape = shape as ConvexCircle;
                if (circleShape == null)
                {
                                        #if DEBUG
                    Debug.LogError("Unable to down cast ConvexShape to ConvexCircle");
                                        #endif
                }
                return(ContactWithCircle(circleShape));

            case ConvexShapeID.Point:            //Point
                ConvexPoint pointShape = shape as ConvexPoint;
                if (pointShape == null)
                {
                                        #if DEBUG
                    Debug.LogError("Unable to down cast ConvexShape to ConvextPoint");
                                        #endif
                }
                return(ContactWithPoint(pointShape));

            case ConvexShapeID.Unknow:            //Unknow
                                #if DEBUG
                Debug.LogError("Unknow convex shape");
                                #endif
                break;
            }

            return(CollisionResult.None);
        }
Beispiel #2
0
 protected override CollisionResult ContactWithPoint(ConvexPoint otherPoint)
 {
     return(ContainPoint2D(otherPoint.Center));
 }
Beispiel #3
0
 /**
  * Subclass must override
  **/
 protected abstract CollisionResult ContactWithPoint(ConvexPoint otherPoint);