private void MakeDungeon(Vec size, int depth) { // clear the grid mOpenCount = 0; mMadeUpStair = false; mMadeDownStair = false; mDungeon.Tiles.Fill(pos => new Tile(TileType.Wall)); mFactory = new FeatureFactory(this, depth); // create a starting room mUnusedConnectors.Clear(); mStartPos = mFactory.MakeStartingRoom().Center; for (int tries = 0; (tries < mOptions.MaxTries) && (mUnusedConnectors.Count > 0); tries++) { // pull off the first unused connector Connector connector = mUnusedConnectors[0]; bool success = false; switch (connector.From) { case ConnectFrom.Room: // try to add a hall success = mFactory.MakeHall(connector); break; case ConnectFrom.Hall: var feature = mDungeon.Game.Content.Features.CreateOne(depth); success = mFactory.CreateFeature(feature, connector); break; } // the connector has been tried mUnusedConnectors.Remove(connector); // if we failed to connect something, move the connector to the end of the list // since it pulls connectors from the beginning, this should encourage // the dungeon to spread out first instead of just hammering the same crowded // connectors over and over again. if (!success) { mUnusedConnectors.Add(connector); } } }
public RoomDecorator(FeatureFactory factory, Action <Vec> insideRoom) { mInsideRoom = insideRoom; mFactory = factory; mDecoration = mFactory.ChooseInnerWall(); }