public void CollideItems(GraphicalManager graphicalManager, List <IGraphicalItem> graphicalItems, List <IGraphicalItem> otherGraphicalItems) { foreach (IGraphicalItem curItem in graphicalItems) { foreach (IGraphicalItem otherItem in otherGraphicalItems) { Collided(curItem, otherItem); } } }
public void CheckCollisions(GraphicalManager otherGraphicalManager) { List <IGraphicalItem> myItemsToCollide = new List <IGraphicalItem>(); List <IGraphicalItem> otherItemsToCollide = new List <IGraphicalItem>(); foreach (IGraphicalItem curItem in GraphicalItems) { Rectangle myRect = curItem.CalculateBoundingBox(); foreach (IGraphicalItem otherItem in otherGraphicalManager.GraphicalItems) { Rectangle otherRect = otherItem.CalculateBoundingBox(); if (myRect.IntersectsWith(otherRect) && !myItemsToCollide.Contains(curItem) && !otherItemsToCollide.Contains(otherItem)) { myItemsToCollide.Add(curItem); otherItemsToCollide.Add(otherItem); } } } CollideItems(this, myItemsToCollide, otherItemsToCollide); }