Search Unity

Random Dungeon Generator for the Asset Store

Discussion in 'Works In Progress - Archive' started by Spartan301, May 28, 2012.

  1. Spartan301

    Spartan301

    Joined:
    Aug 31, 2011
    Posts:
    20
    Hey guys I just want to show you some progress that I have on a personal project of mine. I plan on improving it and eventually releasing it on the Asset Store, so any comments would be appreciated.



    The dungeon generation algorithm I used is outlined here: http://roguebasin.roguelikedevelopment.org/index.php?title=Dungeon-Building_Algorithm. I want to be clear here and say that I did not create this algorithm, I just implemented it in Unity. Basically what I do is I create a room at the center of the map and then choose a wall along that room and place a new feature in the dungeon after checking if there is enough space for it. This process is then repeated a set number of times. The dungeon data is stored in a 2D array of characters with a convention of 'f' being a floor and 'w' being a wall, etc.

    Legend:
    Green- wall
    White- floor
    Dark blue- door
    Light blue- secret door



    Currently there are three types of features that can be placed in the dungeon: corridors, rooms, and custom rooms. Corridors are simple walkways that are 1 grid space wide and have a random length. Rooms have a random width and height, and also can be either a rectangular or circular room. Custom rooms are created in a txt file which is read and placed into the dungeon.

    Example custom room file (the number at the top tells the script how many custom rooms there are to choose from, and the ~ is put to divided the data of the two rooms:
    Code (csharp):
    1. 2
    2.     wwwwwww
    3.     wfffffw
    4.     wwwwwfw
    5.       w wfw
    6.      wfwwfw
    7.     wfffsfw
    8.      wfwwfw
    9.       w wfw
    10.     wwwwwfw
    11.     wfffffw
    12.     wwwwwww
    13. ~
    14. wwwwwwwww
    15. wfffffffw
    16. wfwfffwfw
    17. wfffffffw
    18. wfwfffwfw
    19. wfffffffw
    20. wfwfffwfw
    21. wfffffffw
    22. wwwwwwwww
    The look and feel of the dungeon can be modified by changing the probabilities that each type of feature has of being placed. For example one could create a corridor heavy dungeon with very few rooms, or one could create a dungeon made almost entirely out of custom rooms. The size of the dungeon would only be limited by the performance of the machine running the script. (The largest I have created is a 250x250 size dungeon, and it load up fine)



    Current Plans:
    Right now I plan on having this implemented as an editor script with the dungeon being made prior to the game. The reason I am doing this is because of the performance cost of instantiating an object for every grid space in the dungeon. I might try to implement a 'minecraft' solution and divide the map into chunks and load each piece as the player gets closer and remove the chunk as they move away.

    I want to implement a simple inspector gui for inputting data like the dungeon width and height.

    I want to implement a tile editor as an alternative to creating custom rooms in a text editor. Does anyone know of any good resources for that sort of thing?

    I would like to implement random treasure and mob placement (The mobs probably wouldn't have any ai, that would be to far outside of the scope of this project)

    I want to have some basic prefabs for the dungeon that are already textured and working (ie. usable doors, treasure drops). I have found a free texture pack on the Asset Store I might use that if I can get permission from him.



    I would appreciate any comments, criticisms and suggestion.
    Thank you.
     
  2. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Looks very cool.
     
  3. XavLar

    XavLar

    Joined:
    Feb 14, 2012
    Posts:
    143
    Could it be optimized for 1st Person?
     
  4. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    I suggest making sure that all hallways end in a room. it's weird to have a hallway just end.
     
  5. Spartan301

    Spartan301

    Joined:
    Aug 31, 2011
    Posts:
    20
    By optimized do you mean only rendering the blocks that are in view of the player? I could do that but I have no idea how so I would need to do some more research.

    I might try to find a way to do that only on the corridors on the edge of the dungeon. I think some corridor dead ends are fine, but I agree that those useless branches of corridors look awkward on the edge of the dungeon. However, remember that eventually the corridors themselves might have treasure and traps, so even a dead end would still provide a gameplay experience.
     
  6. xTroMx

    xTroMx

    Joined:
    Dec 29, 2011
    Posts:
    4
    When are you planning to release it ? and for how much ?
     
  7. Spartan301

    Spartan301

    Joined:
    Aug 31, 2011
    Posts:
    20
    I have college finals coming up so I probably will not be releasing it within the next few weeks. There are still several improvements that I want to make before I consider it worthy of being sold. Price wise I was thinking along the lines of $25-30 but don't know if that is too much to ask for something like this.
     
  8. TehWut

    TehWut

    Joined:
    Jun 18, 2011
    Posts:
    1,577
    Are the rooms modular? you said that hallway length can be randomly selected, and it looks as if they are generated from cubes - a mix of both?
     
  9. Spartan301

    Spartan301

    Joined:
    Aug 31, 2011
    Posts:
    20
    The whole dungeon is based on a modular grid based system. So when I said a hallway of random length can be created, I meant that it can can have a length of a random number of grid spaces (i.e. 3,5, and 7 could be the corridor length, but 6.5 could not).
     
  10. garato78

    garato78

    Joined:
    Jun 4, 2012
    Posts:
    3
    Spartan301 I find this all very interesting. one question I had however is if it is possible to use this on a 3d scale. I have sent you an message with a few other inquiries.
     
  11. Spartan301

    Spartan301

    Joined:
    Aug 31, 2011
    Posts:
    20
    Sent you a PM, sorry for the delay
     
  12. xTroMx

    xTroMx

    Joined:
    Dec 29, 2011
    Posts:
    4
    any updates on a release date ?