public QuadTree(Vector2 mapSize)
 {
     this.mapSize = mapSize;
     leafDictionary = new LeafDictionary(this);
     Rectangle mapRectangle = new Rectangle(0, 0, (int)Math.Ceiling(mapSize.X), (int)Math.Ceiling(mapSize.Y));
     root = new InternalNode(true, null, mapRectangle, leafDictionary);
 }
Example #2
0
 public Node(InternalNode parent, Rectangle mapSpace, LeafDictionary leafDictionary)
 {
     id                  = nextI++;
     this.parent         = parent;
     this.leafDictionary = leafDictionary;
     this.mapSpace       = mapSpace;
 }
 public Node(InternalNode parent, Rectangle mapSpace, LeafDictionary leafDictionary)
 {
     id = nextI++;
     this.parent = parent;
     this.leafDictionary = leafDictionary;
     this.mapSpace = mapSpace;
 }
Example #4
0
 public QuadTree(Vector2 mapSize, GetTreePosition positionFunc)
 {
     this.mapSize = mapSize;
     this.positionFunc = positionFunc;
     leafDictionary = new LeafDictionary(this);
     Rectangle mapRectangle = new Rectangle(0, 0, (int)Math.Ceiling(mapSize.X), (int)Math.Ceiling(mapSize.Y));
     root = new InternalNode(true, null, mapRectangle, leafDictionary, this.positionFunc);
 }
Example #5
0
 public Node(InternalNode parent, Rectangle mapSpace, LeafDictionary leafDictionary, GetTreePosition positionFunc)
 {
     id = nextI++;
     this.parent = parent;
     this.leafDictionary = leafDictionary;
     this.mapSpace = mapSpace;
     this.positionFunc = positionFunc;
 }
Example #6
0
        public QuadTree(Vector2 mapSize)
        {
            this.mapSize   = mapSize;
            leafDictionary = new LeafDictionary(this);
            Rectangle mapRectangle = new Rectangle(0, 0, (int)Math.Ceiling(mapSize.X), (int)Math.Ceiling(mapSize.Y));

            root = new InternalNode(true, null, mapRectangle, leafDictionary);
        }
        public InternalNode(Boolean root, InternalNode parent, Rectangle mapSpace, LeafDictionary leafDictionary, GetTreePosition positionFunc)
            : base(parent, mapSpace, leafDictionary, positionFunc)
        {
            this.root = root;
            int halfWidth = mapSpace.Width / 2;
            int halfHeight = mapSpace.Height / 2;

            Rectangle swRectangle = new Rectangle(mapSpace.X, mapSpace.Y, halfWidth, halfHeight);
            Rectangle seRectangle = new Rectangle(mapSpace.X + halfWidth, mapSpace.Y, mapSpace.Width - halfWidth, halfHeight);
            Rectangle nwRectangle = new Rectangle(mapSpace.X, mapSpace.Y + halfHeight, halfWidth, mapSpace.Height - halfHeight);
            Rectangle neRectangle = new Rectangle(mapSpace.X + halfWidth, mapSpace.Y + halfHeight, mapSpace.Width - halfWidth, mapSpace.Height - halfHeight);

            Node nw = new Leaf(this, nwRectangle, leafDictionary, positionFunc);
            Node ne = new Leaf(this, neRectangle, leafDictionary, positionFunc);
            Node sw = new Leaf(this, swRectangle, leafDictionary, positionFunc);
            Node se = new Leaf(this, seRectangle, leafDictionary, positionFunc);
            children.Add(nw);
            children.Add(ne);
            children.Add(sw);
            children.Add(se);
        }
        public InternalNode(Boolean root, InternalNode parent, Rectangle mapSpace, LeafDictionary leafDictionary)
            : base(parent, mapSpace, leafDictionary)
        {
            this.root = root;
            int halfWidth  = mapSpace.Width / 2;
            int halfHeight = mapSpace.Height / 2;

            Rectangle swRectangle = new Rectangle(mapSpace.X, mapSpace.Y, halfWidth, halfHeight);
            Rectangle seRectangle = new Rectangle(mapSpace.X + halfWidth, mapSpace.Y, mapSpace.Width - halfWidth, halfHeight);
            Rectangle nwRectangle = new Rectangle(mapSpace.X, mapSpace.Y + halfHeight, halfWidth, mapSpace.Height - halfHeight);
            Rectangle neRectangle = new Rectangle(mapSpace.X + halfWidth, mapSpace.Y + halfHeight, mapSpace.Width - halfWidth, mapSpace.Height - halfHeight);

            Node nw = new Leaf(this, nwRectangle, leafDictionary);
            Node ne = new Leaf(this, neRectangle, leafDictionary);
            Node sw = new Leaf(this, swRectangle, leafDictionary);
            Node se = new Leaf(this, seRectangle, leafDictionary);

            children.Add(nw);
            children.Add(ne);
            children.Add(sw);
            children.Add(se);
        }
Example #9
0
 public Leaf(InternalNode parent, Rectangle mapSpace, LeafDictionary leafDictionary, GetTreePosition positionFunc)
     : base(parent, mapSpace, leafDictionary, positionFunc)
 {
     unitList = new GameObjectListManager();
 }
 public Leaf(InternalNode parent, Rectangle mapSpace, LeafDictionary leafDictionary)
     : base(parent, mapSpace, leafDictionary)
 {
     unitList = new GameObjectListManager();
 }
Example #11
0
 public Leaf(InternalNode parent, Rectangle mapSpace, LeafDictionary leafDictionary)
     : base(parent, mapSpace, leafDictionary)
 {
     unitList = new GameObjectListManager();
 }