Example #1
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 #3
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;
 }
        public InternalNode(Boolean root, InternalNode parent, Rectangle mapSpace)
            : base(parent)
        {
            this.root = root;
            this.mapSpace = mapSpace;
            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);

            nw = new Leaf(this, nwRectangle);//Node.ConstructBranch(this, nwRectangle, height - 1);
            ne = new Leaf(this, neRectangle);//Node.ConstructBranch(this, neRectangle, height - 1);
            sw = new Leaf(this, swRectangle);//Node.ConstructBranch(this, swRectangle, height - 1);
            se = new Leaf(this, seRectangle);//Node.ConstructBranch(this, seRectangle, height - 1);
        }
Example #5
0
        private void Expand()
        {
            if (MapSpace.Width > 1 && MapSpace.Height > 1)
            {
                Node newNode = new InternalNode(false, this.Parent, this.MapSpace, leafDictionary);// (this.Parent, this.mapSpace, 2);
                this.Parent.Replace(this, newNode);
                foreach (CompositePhysicalObject obj in unitList.GetList <CompositePhysicalObject>())
                {
                    this.Remove(obj);
                    if (!newNode.Add(obj))
                    {
                        this.Parent.Move(obj);
                        //throw new Exception("Failed to add after move");
                    }
                }

                leafDictionary.DestroyLeaf(this);
            }
        }
        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 #8
0
 public Leaf(InternalNode parent, Rectangle mapSpace, LeafDictionary leafDictionary, GetTreePosition positionFunc)
     : base(parent, mapSpace, leafDictionary, positionFunc)
 {
     unitList = new GameObjectListManager();
 }
Example #9
0
        private void Expand()
        {
            if (MapSpace.Width > 1 && MapSpace.Height > 1)
            {
                Node newNode = new InternalNode(false, this.Parent, this.MapSpace, leafDictionary, this.PositionFunc);// (this.Parent, this.mapSpace, 2);
                this.Parent.Replace(this, newNode);
                foreach (PhysicalObject obj in unitList.GetList<PhysicalObject>())
                {
                    this.Remove(obj);
                    if (!newNode.Add(obj))
                    {
                        this.Parent.Move(obj);
                        //throw new Exception("Failed to add after move");
                    }
                }

                leafDictionary.DestroyLeaf(this);
            }
        }
 public Leaf(InternalNode parent, Rectangle mapSpace, LeafDictionary leafDictionary)
     : base(parent, mapSpace, leafDictionary)
 {
     unitList = new GameObjectListManager();
 }
Example #11
0
 public void DisconnectFromParent()
 {
     parent = null;
 }
Example #12
0
 public Leaf(InternalNode parent, Rectangle mapSpace)
     : base(parent)
 {
     this.mapSpace = mapSpace;
     unitList = new List<CompositePhysicalObject>();
 }
Example #13
0
 private void Expand()
 {
     if (mapSpace.Width > 1 && mapSpace.Height > 1)
     {
         Node newNode = new InternalNode(false, this.Parent, this.mapSpace);// (this.Parent, this.mapSpace, 2);
         this.Parent.Replace(this, newNode);
         foreach (CompositePhysicalObject obj in unitList)
         {
             if (!newNode.Add(obj))
             {
                 throw new Exception("Failed to add after move");
             }
         }
     }
 }
Example #14
0
 public Leaf(InternalNode parent, Rectangle mapSpace, LeafDictionary leafDictionary)
     : base(parent, mapSpace, leafDictionary)
 {
     unitList = new GameObjectListManager();
 }
Example #15
0
 public void DisconnectFromParent()
 {
     parent = null;
 }
Example #16
0
 public Node(InternalNode parent)
 {
     id = nextI++;
     this.parent = parent;
 }