dzherihov / RandomGenerateWorld

A universal algorithm for any game where procedural level generation is required.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dungeon Procedural Level Generator

preview

Introduction

A universal algorithm for any game where procedural level generation is required. The generator can easily create up to 100 rooms without time delays.

Asset features:

  • fast and thought-out algorithm for generating dungeons based on a binary matrix;
  • conveniently create your own rooms using tile mappings
  • ability to customize dungeon branching levels;
  • each generation has a unique dungeon.

Asset included:

  • One demo scene;
  • 16 prefabs of various rooms;
  • One demo tilemap.

Example Scenes

An example scene demonstrates the operation of the algorithm. In order to see the algorithm in action, you need to run the scene. A dungeon will be generated on your screen.
For new generation press «R».

Variety of rooms

All rooms are prefabs, in turn, each can be customized to taste:

prefabs

The first digit in the name indicates the number of exits from the room, the second is the serial number. For example, a prefab named «3_2» means that the room contains three exits:

example_room

A prefab named "noRoom" is needed to fill the empty space (where there are no rooms) when generating the level.

To edit rooms, you need to use the tilemap tool. But this is just an example, you can do it as you like:

edit_room

Generator settings

For the functioning of the dungeon generator, you need to connect two scripts to the scene:

  1. GenerationMap - this script, which generates a binary matrix, on the basis of which, our dungeon will be built;
  2. ArrayRooms - this script is directly responsible for the visual display of the dungeon itself. Based on the generated matrix, it compares our rooms and places them on the stage

In the inspector, you need to configure the «ArrayRoom» script, add our room prefabs to the Room array field. It is also necessary to indicate the link to the parent object in the «Rooms Parent» field, in which the generated rooms will be placed according to the hierarchy of the object. It is necessary that everything is grouped.

The "Scale Multy" field is a multiplier for increasing the scale parameter for the generated maze.

Boolean value "Client" - if this option is activated, the maze will be generated by the given matrix, in this case the value of the matrix is taken from the value of the "GetMatrix" field. This feature is implemented for network games when the server generates a dungeon and sends a matrix to all clients. If you need a new generation every time you run the level, leave the "Client" field false.

Field "Get Max Branching" - takes the value of the number of branches of the maze from the center. For example, if the value is 10, then in each direction (left, right, top, bottom) there will be a permissible probability of generating 10 rooms.

The "Spawn Point" and "FinishPoint" fields contain the prefab of the corresponding points, which according to a special algorithm will be located on the generated dungeon, while at the same time unraveling at maximum distance from each other. This opportunity gives the developer to place his character in the right place in the dungeon.

settings_room

In the «GeneratorMap» script inspector, specify the maximum number of branches for generating rooms in the «MaxRoomInspector» field:

settings_generator

For example, if you specify a value of 3, then three rooms can be generated from the center in every four directions.

How the algorithm works

algorithm

Support

If you are confused by something, you can write to denis@proger.xyz and we will do our best to contact you immediately. We hope you enjoy our asset and good luck in creating your games!

About

A universal algorithm for any game where procedural level generation is required.

License:MIT License


Languages

Language:C# 100.0%