public Quadtree(Tile[,] leveltiles, int layers) { levelBoundingBox = new Rectangle( 0, 0, leveltiles.GetLength(1) * Tile.TILE_SIZE, leveltiles.GetLength(0) * Tile.TILE_SIZE); rootNode = new QuadTreeNode(levelBoundingBox, layers, leveltiles); current_rects = new List<Rectangle>(); MaxLayer = layers; enemyCollisionTiles = new List<Tile>[Environment.ProcessorCount]; enemyiterateNodes = new List<QuadTreeNode>[Environment.ProcessorCount]; }
private QuadTreeNode[] GenerateChildNodes(Rectangle parentRect,int layernumber,int maxLayer,Tile[,] leveltiles) { QuadTreeNode[] childs; layernumber++; if (layernumber + 1 >= maxLayer) { childs = new QuadTreeNode[1]; childs[0] = new QuadTreeNode(parentRect, leveltiles); } else { childs = new QuadTreeNode[4]; childs[0] = new QuadTreeNode(parentRect, QTI.LeftTop, layernumber, maxLayer, leveltiles); childs[1] = new QuadTreeNode(parentRect, QTI.RightTop, layernumber, maxLayer, leveltiles); childs[2] = new QuadTreeNode(parentRect, QTI.LeftBottom, layernumber, maxLayer, leveltiles); childs[3] = new QuadTreeNode(parentRect, QTI.RightBottom, layernumber, maxLayer, leveltiles); } return childs; }