Esempio n. 1
0
 /// <summary>
 /// Potentially turns this room into a wall based
 /// on specification from currentCommand.  Rooms
 /// that are not turned into walls are added to
 /// activeFloorSprawler and are counted toward the
 /// number of rooms created by currentCommand.
 /// </summary>
 /// <param name="roomToFinalize"></param>
 private void FinalizeAddingRoom(Room roomToFinalize)
 {
     roomToFinalize.IsWall = TryForWallRoom();
     if (roomToFinalize.IsNotWall)
     {
         currentCommand.DecrementRoomsLeft();
         activeFloorSprawler.addRoom(roomToFinalize);
     }
 }
Esempio n. 2
0
 private void TryToRepopulateSprawler()
 {
     activeFloorSprawler = new FloorSprawler();
     foreach (Room r in floorBeingBuilt.GetRooms())
     {
         if (r.IsNotWall && !r.HasAllNeighbors)
         {
             activeFloorSprawler.addRoom(r);
         }
     }
 }
Esempio 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;
 }
Esempio n. 4
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;
 }
Esempio n. 5
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;
        }
Esempio n. 6
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);
        }