示例#1
0
        public LevelCell FindObjectContainmentCell(LevelObject obj)
        {
            SBSBounds objBounds = obj.Bounds;

            LevelCell curCell = this;

            while (curCell.parent != null && !curCell.bounds.Contains(objBounds))
            {
                curCell = curCell.parent;
            }

            int cellIndex, numCells;

            do
            {
                List <LevelCell> curChildren = curCell.children;
                numCells = curChildren.Count;
                for (cellIndex = 0; cellIndex < numCells; ++cellIndex)
                {
                    LevelCell child = curChildren[cellIndex];
                    if (child.bounds.Contains(objBounds))
                    {
                        curCell = child;
                        break;
                    }
                }
            }while (cellIndex != numCells);

            return(curCell);
        }
示例#2
0
        public LevelCell(SBSBounds _bounds)
        {
            bounds           = _bounds;
            objects          = new List <LevelObject>();
            numObjectsByCat  = new Dictionary <string, int>();
            numObjectsByMask = new int[32];
            parent           = null;
            children         = new List <LevelCell>();

            for (int bit = 0; bit < 32; ++bit)
            {
                numObjectsByMask[bit] = 0;
            }
        }