Exemplo n.º 1
0
 private void TryToRepopulateSprawler()
 {
     activeFloorSprawler = new FloorSprawler();
     foreach (Room r in floorBeingBuilt.GetRooms())
     {
         if (r.IsNotWall && !r.HasAllNeighbors)
         {
             activeFloorSprawler.addRoom(r);
         }
     }
 }
Exemplo n.º 2
0
 public FloorGenerator(uint[] commands, int numberOfRooms, int seed, bool wallAllRooms)
 {
     roomsToGenerate     = numberOfRooms;
     floorBeingBuilt     = new Floor();
     allCommands         = GenerationCommand.ParseArray(commands);
     activeFloorSprawler = new FloorSprawler();
     activeFloorSprawler.addRoom(floorBeingBuilt.StartRoom);
     commandCount = roomsBuilt = 0;
     RandomUtility.Initialize(seed);
     this.wallAllRooms = wallAllRooms;
 }
Exemplo n.º 3
0
 public void Reset()
 {
     floorBeingBuilt = new Floor();
     foreach (GenerationCommand command in allCommands)
     {
         command.ResetRoomsLeft();
     }
     activeFloorSprawler = new FloorSprawler();
     activeFloorSprawler.addRoom(floorBeingBuilt.StartRoom);
     commandCount = roomsBuilt = 0;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Takes all rooms in this FloorSprawler and
        /// rebuilds this FloorSprawler's contents so
        /// that the order from "front" to "back" is
        /// different than before.
        ///
        /// This is done by taking either the first or
        /// last element of the existing FloorSprawler
        /// and adding it to either the "front" or the
        /// "back" of a new FloorSprawler.  Should kind
        /// of turn the contents inside out.
        ///
        /// I checked how this performs in an outside
        /// project.  It performs semi-well with a high
        /// tendency to leave the outer sections
        /// less sorted than inner sections.  Therefore
        /// it should be rewritten.
        /// </summary>
        public void shuffleRooms()
        {
            FloorSprawler newSprawler             = new FloorSprawler();
            bool          originalDepthFirstValue = this.IsDepthFirst;

            while (this.FrontNode != null)
            {
                this.IsDepthFirst = RandomUtility.RandomBool();

                newSprawler.addRoom(this.removeNextRoom());
            }
            this.FrontNode     = newSprawler.FrontNode;
            this.EndNode       = newSprawler.EndNode;
            this.NumberOfRooms = newSprawler.NumberOfRooms;
            this.IsDepthFirst  = originalDepthFirstValue;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Changes the order of input by adding the Room
        /// objects to a temporary FloorSprawler and using
        /// the shuffleRooms method of that class.  Returns
        /// as a new object.
        /// </summary>
        /// <param name="input"></param>
        /// <returns>A List of type Room where the order is
        /// different than the order within input.</returns>
        private List <Room> GetShuffledRoomArray(List <Room> input)
        {
            FloorSprawler tempSprawler = new FloorSprawler();

            foreach (Room r in input)
            {
                if (r != null)
                {
                    tempSprawler.addRoom(r);
                }
            }
            tempSprawler.shuffleRooms();
            List <Room> toReturn = new List <Room>();

            while (tempSprawler.HasNextRoom)
            {
                toReturn.Add(tempSprawler.removeNextRoom());
            }
            return(toReturn);
        }