static public void RevCollide(GameObject pSafeTreeA, GameObject pSafeTreeB) { // A vs B GameObject pNodeA = pSafeTreeA; GameObject pNodeB = pSafeTreeB; while (pNodeA != null) { // Restart compare pNodeB = pSafeTreeB; while (pNodeB != null) { // who is being tested? //Debug.WriteLine("ColPair: test: {0}({2}), {1}({3})", pNodeA.name, pNodeB.name, pNodeA.GetHashCode(), pNodeB.GetHashCode()); // Get rectangles ColRect rectA = pNodeA.GetColObject().poColRect; ColRect rectB = pNodeB.GetColObject().poColRect; // test them if (ColRect.Intersect(rectA, rectB)) { // Boom - it works (Visitor in Action) // Debug.WriteLine("Collision Detected!"); pNodeA.Accept(pNodeB); break; } pNodeB = (GameObject)pNodeB.GetPrevSibling(); } pNodeA = (GameObject)pNodeA.GetPrevSibling(); } }