Пример #1
0
 public static bool touches(List<ObjectBounds2D> list, ObjectBounds2D obj)
 {
     foreach(var objBounds in list)
     {
         if (objBounds.touches(obj)) return true;
     }
     return false;
 }
Пример #2
0
    public bool touches(ObjectBounds2D toCheck)
    {
        if (!initialized) throw new System.Exception("This Object Bounds is not initialized");
        if(boundsDebugger)
        {
            Debug.Log("---------------------------------");
            Debug.Log((toCheck.z1 > z1 && toCheck.z1 < z2) + "     " + z1 + "        " + toCheck.z1 + "      " + z2);
            Debug.Log((z1 > toCheck.z1 && z1 < toCheck.z2) + "      " + toCheck.z1 + "   " + z1 + "      " + toCheck.z2);

            Debug.Log((toCheck.x1 > x1 && toCheck.x1 < x2) + "     " + x1 + "        " + toCheck.x1 + "      " + x2);
            Debug.Log((x1 > toCheck.x1 && x1 < toCheck.x2) + "      " + toCheck.x1 + "   " + x1 + "      " + toCheck.x2);

            Debug.Log("---------------------------------");
        }

        bool collidesOnX = (toCheck.x1 > x1 && toCheck.x1 < x2) || (x1 > toCheck.x1 && x1 < toCheck.x2);
        bool collidesOnZ = (toCheck.z1 > z1 && toCheck.z1 < z2) || (z1 > toCheck.z1 && z1 < toCheck.z2);

        return collidesOnX && collidesOnZ;
    }