public static List <GameObject> GetAllOverlapping(GameObject physObject) { _tempList.Clear(); if (Mode == PhysMode.CircleBox) { PointFloat physPos = physObject.GetPosition(); float physSize = physObject.GetPhysSize(); foreach (GameObject obj in TomatoMainEngine.GameObjects) { if (obj.HasPhysics() && obj != physObject && !(physObject.IsParticle() && obj.Type == physObject.Type)) { PointFloat objPos = obj.GetPosition(); float gemX = Math.Abs(objPos.x - physPos.x); float gemY = Math.Abs(objPos.y - physPos.y); float fDistance = gemX + gemY - obj.GetPhysSize(); if (fDistance < physSize) { _tempList.Add(obj); } } } } else { PointFloat physPos = physObject.GetPosition(); PointFloat physSize = physObject.GetSize(); foreach (GameObject obj in TomatoMainEngine.GameObjects) { if (obj.HasPhysics() && obj != physObject && !(physObject.IsParticle() && obj.Type == physObject.Type)) { if (IsInBox(physPos, obj.GetPosition(), physSize, obj.GetSize())) { _tempList.Add(obj); } } } } return(_tempList); }
public static bool IsOverlappingInCircle(GameObject physObject1, GameObject physObject2) { PointFloat physPos = physObject1.GetPosition(); float physSize = physObject1.GetPhysSize(); if (physObject2.HasPhysics() && !(physObject2.IsParticle() && physObject2.Type == physObject1.Type)) { PointFloat objPos = physObject2.GetPosition(); float fDistance = (float)(Math.Pow(physPos.x - objPos.x, 2) + Math.Pow(physPos.y - objPos.y, 2)); if (fDistance < physSize + physObject2.GetPhysSize()) { return(true); } } return(false); }
public static bool IsOverlappingInCircle(GameObject physObject1, GameObject physObject2) { PointFloat physPos = physObject1.GetPosition(); float physSize = physObject1.GetPhysSize(); if (physObject2.HasPhysics() && !( physObject2.IsParticle () && physObject2.Type == physObject1.Type)) { PointFloat objPos = physObject2.GetPosition(); float fDistance = (float)( Math.Pow(physPos.x-objPos.x, 2) + Math.Pow(physPos.y-objPos.y, 2) ); if ( fDistance < physSize + physObject2.GetPhysSize() ) { return true; } } return false; }
public static List<GameObject> GetAllOverlapping(GameObject physObject) { _tempList.Clear(); if(Mode == PhysMode.CircleBox){ PointFloat physPos = physObject.GetPosition(); float physSize = physObject.GetPhysSize(); foreach (GameObject obj in TomatoMainEngine.GameObjects) { if (obj.HasPhysics() && obj != physObject && !(physObject.IsParticle() && obj.Type == physObject.Type)) { PointFloat objPos = obj.GetPosition(); float gemX = Math.Abs(objPos.x - physPos.x); float gemY = Math.Abs(objPos.y - physPos.y); float fDistance = gemX + gemY - obj.GetPhysSize(); if (fDistance < physSize) { _tempList.Add(obj); } } } } else { PointFloat physPos = physObject.GetPosition(); PointFloat physSize = physObject.GetSize(); foreach (GameObject obj in TomatoMainEngine.GameObjects) { if (obj.HasPhysics() && obj != physObject && !(physObject.IsParticle() && obj.Type == physObject.Type)) { if (IsInBox(physPos, obj.GetPosition(), physSize, obj.GetSize())) { _tempList.Add(obj); } } } } return _tempList; }