示例#1
0
        //test for collision against a specific object
        private Actor CheckCollision(GameTime gameTime, Actor3D actor3D)
        {
            //dont test for collision against yourself - remember the player is in the object manager list too!
            if (this != actor3D)
            {
                if (actor3D is CollidablePrimitiveObject)
                {
                    CollidablePrimitiveObject collidableObject = actor3D as CollidablePrimitiveObject;
                    if (CollisionPrimitive.Intersects(collidableObject.CollisionPrimitive, Transform3D.TranslateIncrement))
                    {
                        return(collidableObject);
                    }
                }
                else if (actor3D is CollidableZoneObject)
                {
                    CollidableZoneObject zoneObject = actor3D as CollidableZoneObject;
                    if (CollisionPrimitive.Intersects(zoneObject.CollisionPrimitive, Transform3D.TranslateIncrement))
                    {
                        return(zoneObject);
                    }
                }
            }

            return(null);
        }
示例#2
0
        private Actor CheckCollision(GameTime gameTime, Actor3D actor3D, Vector3 translation)
        {
            if (!Equals(actor3D))
            {
                if (actor3D is CollidablePrimitiveObject)
                {
                    CollidablePrimitiveObject collidableObject = actor3D as CollidablePrimitiveObject;
                    if (CollisionPrimitive.Intersects(collidableObject.CollisionPrimitive, translation))
                    {
                        return(collidableObject);
                    }
                }
                else if (actor3D is CollidableZoneObject)
                {
                    CollidableZoneObject zoneObject = actor3D as CollidableZoneObject;
                    if (CollisionPrimitive.Intersects(zoneObject.CollisionPrimitive, translation))
                    {
                        return(zoneObject);
                    }
                }
            }

            return(null);
        }