/// <summary> /// Generates a normal node of the Quadtree. /// This one contains no Tiles, but conatins 4 ChildNodes /// </summary> /// <param name="parentRect">The Rectangle of the Parent Node. /// The Node will generate his own rectangle depending on the Indicator</param> /// <param name="indicator">The Indicator controlls which Position this Node will have in the Parent Node</param> /// <param name="layernumber">The current Layernumber</param> /// <param name="maxLayer">The Maximum count of Layers in the Quadtree</param> /// <param name="leveltiles">The Tiles from the Level which should be included into the Quadtree</param> public QuadTreeNode(Rectangle parentRect,QTI indicator,int layernumber,int maxLayer,Tile[,] leveltiles) { ownRect = GenerateRect(parentRect, indicator); childTreeNodes = GenerateChildNodes(ownRect, layernumber, maxLayer, leveltiles); }
private Rectangle GenerateRect(Rectangle sourceRectangle, QTI indicator) { Point temppos; Point tempsize; tempsize = new Point( sourceRectangle.Width / 2, sourceRectangle.Height / 2); switch (indicator) { case QTI.LeftBottom: temppos = new Point( sourceRectangle.X, sourceRectangle.Y + sourceRectangle.Height / 2); break; case QTI.LeftTop: temppos = new Point( sourceRectangle.X, sourceRectangle.Y); break; case QTI.RightBottom: temppos = new Point( sourceRectangle.X + sourceRectangle.Width / 2, sourceRectangle.Y + sourceRectangle.Height / 2); break; case QTI.RightTop: temppos = new Point( sourceRectangle.X + sourceRectangle.Width / 2, sourceRectangle.Y); break; default: temppos = new Point( sourceRectangle.X, sourceRectangle.Y); break; } return new Rectangle(temppos.X, temppos.Y, tempsize.X, tempsize.Y); }