Exemplo n.º 1
0
        public void HandleGridCollision(int x, int y)
        {
            var al = EDynamic[x, y];
            var sl = EStatic[x, y];
            var wl = Walls[x, y];

            // Dynamic-Dynamic
            for (int i1 = 0; i1 < al.Count - 1; i1++)
            {
                for (int i2 = i1 + 1; i2 < al.Count; i2++)
                {
                    CollisionController.ProcessCollision(al[i1].CollisionGeometry, al[i2].CollisionGeometry);
                }
            }
            // Dynamic-Static
            if (sl != null)
            {
                for (int i1 = 0; i1 < al.Count; i1++)
                {
                    CollisionController.ProcessCollision(al[i1].CollisionGeometry, sl.CollisionGeometry);
                }
            }
            if (wl != null)
            {
                for (int i1 = 0; i1 < al.Count; i1++)
                {
                    for (int i2 = 0; i2 < wl.Length; i2++)
                    {
                        CollisionController.ProcessCollision(al[i1].CollisionGeometry, wl[i2]);
                    }
                }
            }
        }
Exemplo n.º 2
0
        // Precondition This[x,y] Must Be Active
        public void HandleGridCollision(int x, int y, int dx, int dy)
        {
            // Check Bounds
            int ox = x + dx;

            if (ox < 0 || ox >= numCells.X)
            {
                return;
            }
            int oy = y + dy;

            if (oy < 0 || oy >= numCells.Y)
            {
                return;
            }

            var al1 = EDynamic[x, y];
            var al2 = EDynamic[ox, oy];
            var sl2 = EStatic[ox, oy];
            var wl2 = Walls[ox, oy];

            // Empty Check
            if (al2.Count + (sl2 == null ? 0 : 1) + (wl2 == null ? 0 : 1) < 1)
            {
                return;
            }

            // Dynamic-Dynamic
            for (int i1 = 0; i1 < al1.Count; i1++)
            {
                for (int i2 = 0; i2 < al2.Count; i2++)
                {
                    // Get Rid Of Doubles
                    if (al1[i1].UUID > al2[i2].UUID)
                    {
                        CollisionController.ProcessCollision(al1[i1].CollisionGeometry, al2[i2].CollisionGeometry);
                    }
                }
            }
            // Dynamic-Static
            if (sl2 != null)
            {
                for (int i1 = 0; i1 < al1.Count; i1++)
                {
                    CollisionController.ProcessCollision(al1[i1].CollisionGeometry, sl2.CollisionGeometry);
                }
            }
            if (wl2 != null)
            {
                for (int i1 = 0; i1 < al1.Count; i1++)
                {
                    for (int i2 = 0; i2 < wl2.Length; i2++)
                    {
                        CollisionController.ProcessCollision(al1[i1].CollisionGeometry, wl2[i2]);
                    }
                }
            }
        }