Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public void RemoveGameObj(CGameObject Obj)
 {
     delObjects.Add(Obj);
 }