示例#1
0
 internal void Initiallize(Vec2 min, Vec2 max)
 {
     aabb = gameObject.AddComponent <AABBCollider>();
     aabb.Initiallize(min, max);
     isLeaf          = true;
     includedObjects = new List <PhysicsObject>();
 }
示例#2
0
        public bool IsIntersects(ICollider col)
        {
            if (col is AABBCollider)
            {
                AABBCollider aabb = (AABBCollider)col;
                if (aabb.min.x < (center.x - radius))
                {
                    return(false);
                }
                if (aabb.max.x > (center.x + radius))
                {
                    return(false);
                }
                if (aabb.min.y < (center.y - radius))
                {
                    return(false);
                }
                if (aabb.max.y > (center.y + radius))
                {
                    return(false);
                }

                return(true);
            }
            else if (col is CircleCollider)
            {
                CircleCollider circle = (CircleCollider)col;
                if (center.Distance(circle.center) > ((radius + circle.radius) ^ 2))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }