Пример #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
        public new object Clone()
        {
            CollidablePrimitiveObject primitive = new CollidablePrimitiveObject(ID, ActorType, StatusType, Transform3D.Clone() as Transform3D,
                                                                                EffectParameters.Clone() as EffectParameters, IVertexData.Clone() as IVertexData, CollisionPrimitive.Clone() as ICollisionPrimitive,
                                                                                ObjectManager);

            primitive.ControllerList.AddRange(GetControllerListClone());
            return(primitive);
        }
Пример #3
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);
        }