public static void CheckCollision() { foreach (GameObject gameObject in GameObjects) { bool anyCollision = GameObjects.Any(g => g.X == gameObject.X && g.Y == gameObject.Y && g.Name != gameObject.Name); if (anyCollision) { string collidedObject = GameObjects.Find(g => g.X == gameObject.X && g.Y == gameObject.Y && g.Name != gameObject.Name).Name; string collided = gameObject.Name; CollisionInfo collision; if ((collided.Contains("Snake") && !collidedObject.Contains("Snake")) || (collided.Contains("Fly") && !collidedObject.Contains("Fly"))) { collision = CollisionInfo.AteFly; } else { collision = CollisionInfo.AteTail; } Board.collided(collision); return; } } }