Example #1
0
 /// <summary>
 /// Initializes the tree
 /// </summary>
 public void InitQuadtree()
 {
     _tree = new Quadtree(_boundaries);
     _tree.BuildTree(1, 4);
     _tree.AddRoom();
     _treeIsInit = true;
 }
Example #2
0
    /// <summary>
    /// Recursively add rooms
    /// </summary>
    public void AddRoom()
    {
        // If children exist, call AddRoom to em
        if (_northEast != null)
        {
            _northEast.AddRoom();
        }
        if (_northWest != null)
        {
            _northWest.AddRoom();
        }
        if (_southEast != null)
        {
            _southEast.AddRoom();
        }
        if (_southWest != null)
        {
            _southWest.AddRoom();
        }

        // Else add room to current node
        if (_northEast == null && _northWest == null && _southEast == null && _southWest == null)
        {
            _room = Room.CreateRandomRoom(_box);
            Dungeon.GetInstance().AddRoomToList(_room);
            Dungeon.GetInstance().AddRoomToTiles(_room);
        }
    }