public override void Collide(PhysicalBody other)
 {
     if (!(other is FarseerPhysicalBody))
     {
         return; // TO DO: Farseer needs to respond to Ghost body collisions.
     }
 }
Пример #2
0
        protected virtual Vector2 DetectReflectedForce(PhysicalBody other)
        {
            Vector2 positionVector = other.Position - Position;
            float   angle          = (float)Math.Atan2(positionVector.Y, positionVector.X) - (float)Math.PI;

            return(new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)));
        }
Пример #3
0
        public Mob(MobManager mobManager, PhysicalBody physicalBody)
        {
            IsDestroyed = false;

            MobManager   = mobManager;
            PhysicalBody = physicalBody;
            if (PhysicalBody != null)
            {
                PositionInWorldByUpdate  = PositionInWorld;
                PositionOnScreenByUpdate = PositionOnScreen;
                UpdateCollisionRectangle();
            }
            SetWorldLayer(3);
            MobManager.RegisterMob(this);

            IsDrawEnabled   = true;
            IsUpdateEnabled = true;
            IsCollidable    = true;

            Direction = Vector2.Zero;

            UseHitBox         = false;
            NearbyMobs        = new List <Mob>();
            StepsUntilRefresh = RefreshOffset++ % 20;
        }
Пример #4
0
        public override void Collide(PhysicalBody other)
        {
            // Get the reflected force.
            //Vector2 reflection = DetectReflectedForce(other);

            // Multiply the reflected force by the current linear velocity
            //Vector2 reflectedForce = Vector2.Zero;
            //reflectedForce.X = Math.Abs(NetForces.X);
            //reflectedForce.Y = Math.Abs(NetForces.Y);
            //reflectedForce *= reflection;

            //NetForces = Vector2.Zero;
            //ApplyForce(reflectedForce);
        }
Пример #5
0
        public virtual void Collide(PhysicalBody other)
        {
            Vector2 perpendicular = DetectReflectedForce(other);

            ApplyForce(perpendicular);
        }