Beispiel #1
0
        // Return a list of entities colliding with this entity.
        public IEnumerable <T> GetEntitiesMeeting <T>(Rectangle2I myCollisionBox, CollisionBoxType otherCollisionBoxType, int maxZDistance = 10) where T : Entity
        {
            CollisionTestSettings settings = new CollisionTestSettings(typeof(T), myCollisionBox, otherCollisionBoxType, maxZDistance);

            for (int i = 0; i < entity.RoomControl.Entities.Count; i++)
            {
                T other = entity.RoomControl.Entities[i] as T;
                if (other != null && CollisionTest.PerformCollisionTest(entity, other, settings).IsColliding)
                {
                    yield return(other);
                }
            }
        }
Beispiel #2
0
 public bool IsCollidingWith(Entity other, CollisionBoxType myBoxType, CollisionBoxType otherBoxType, int maxZDistance = 10)
 {
     return(CollisionTest.PerformCollisionTest(entity, other,
                                               new CollisionTestSettings(null, myBoxType, otherBoxType, maxZDistance)).IsColliding);
 }