Example #1
0
 public RoomLeaf(int num)
 {
     parent   = null;
     root     = true;
     children = new List <RoomLeaf>();
     this.num = num;
 }
Example #2
0
 void createTree()
 {
     roomLeaves = new RoomLeaf[17];
     for (int i = 0; i < 17; i++)
     {
         roomLeaves[i] = new RoomLeaf(i + 1);
     }
 }
Example #3
0
 void addChildren(RoomLeaf child)
 {
     if (!child.root)
     {
         child.rotateTree();
     }
     children.Add(child);
     child.parent = this;
     child.root   = false;
 }
Example #4
0
 public void connect(RoomLeaf other)
 {
     if (other.getRoot().num < this.getRoot().num)
     {
         other.addChildren(this);
     }
     else if (other.getRoot().num > this.getRoot().num)
     {
         this.addChildren(other);
     }
 }
Example #5
0
 void rotateTree()
 {
     if (!parent.root)
     {
         parent.rotateTree();
     }
     parent.children.Remove(this);
     parent.root   = false;
     parent.parent = this;
     this.children.Add(parent);
     this.parent = null;
     this.root   = true;
 }
Example #6
0
 public bool isConnectTo(RoomLeaf other)
 {
     return(this.getRoot().num == other.getRoot().num);
 }