コード例 #1
0
ファイル: BoxEntity.cs プロジェクト: Shinmera/factory-reset
 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);
 }
コード例 #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);
         }
     }
 }
コード例 #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));
        }
コード例 #4
0
        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);
        }
コード例 #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));
 }