private void CheckCollisionPair(BattleObjectType type1, BattleObjectType type2) { List <BattleObject> objList1, objList2; if (objListDict.TryGetValue(type1, out objList1) && objListDict.TryGetValue(type2, out objList2)) { for (int i1 = objList1.Count - 1; i1 >= 0; --i1) { BattleObject obj1 = objList1[i1]; for (int i2 = objList2.Count - 1; i2 >= 0; --i2) { BattleObject obj2 = objList2[i2]; if (obj1.valid && obj2.valid && obj1.CheckCollision(obj2)) { obj1.OnCollision(obj2); obj2.OnCollision(obj1); } } } } }