Exemple #1
0
 public bool Contains(BoxEntity box)
 {
     return(Position.X - Size.X - box.Size.X <= box.Position.X &&
            Position.Y - Size.Y - box.Size.Y <= box.Position.Y &&
            box.Position.X <= Position.X + Size.X + box.Size.X &&
            box.Position.Y <= Position.Y + Size.Y + box.Size.Y);
 }
Exemple #2
0
 public void ForEachCollidingEntity(BoxEntity source, Action <Entity> action)
 {
     foreach (Entity e in CollidingEntities)
     {
         if (source.Contains(e.Position) || (e is BoxEntity && source.Contains((BoxEntity)e)))
         {
             action(e);
         }
     }
 }
Exemple #3
0
        public override bool Collide(Entity source, RectangleF tileBB, float timestep, out int direction, out float time, out bool corner)
        {
            if (!(source is IEnemy))
            {
                direction = 0;
                time      = -1;
                corner    = false;
                return(false);
            }

            return(BoxEntity.CollideMovable((Movable)source, tileBB, timestep, out direction, out time, out corner));
        }
        public override bool Collide(Entity source, RectangleF tileBB, float timestep, out int direction, out float time, out bool corner)
        {
            if (BoxEntity.CollideMovable((Movable)source, tileBB, timestep, out direction, out time, out corner))
            {
                direction = direction & ~PassThroughs;

                if (source is Player)
                {
                    if (((Player)source).FallThrough)
                    {
                        direction = direction & ~Chunk.Down;
                    }
                }

                return(direction == 0 ? false : true);
            }

            return(false);
        }
Exemple #5
0
 public override bool Collide(Entity source, RectangleF tileBB, float timestep, out int direction, out float time, out bool corner)
 {
     return(BoxEntity.CollideMovable((Movable)source, tileBB, timestep, out direction, out time, out corner));
 }