public static bool IsCollision(CGameObject A, CGameObject B) { List <CPoint> pointsA = new List <CPoint>(); List <CPoint> pointsB = new List <CPoint>(); pointsA.Add(A.a); pointsA.Add(A.b); pointsA.Add(A.c); pointsA.Add(A.d); pointsB.Add(B.a); pointsB.Add(B.b); pointsB.Add(B.c); pointsB.Add(B.d); CRect rect1 = A.GetRect(); CRect rect2 = B.GetRect(); foreach (var point in pointsA) { if (rect2.IsPiontInside(point)) { return(true); } } foreach (var point in pointsB) { if (rect1.IsPiontInside(point)) { return(true); } } return(false); }
public List <CGameObject> GetCollisions(CGameObject Obj) { List <CGameObject> cGameObjects = new List <CGameObject>(); foreach (CGameObject obj in objects) { if (obj == Obj) { continue; } if (CGameObject.IsCollision(Obj, obj)) { cGameObjects.Add(obj); } } return(cGameObjects); }
public void RemoveGameObj(CGameObject Obj) { delObjects.Add(Obj); }