O'Reilly logo

Procedural Content Generation for Unity Game Development by Ryan Watkins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

DungeonManager

Our dungeon generator class will be called DungeonManager. The class will create the data the dungeon is made of and pass it to the BoardManager class to be built on screen. First, we need to create the C# script. Go to the Scripts folder and create a new C# script called DungeonManager.cs.

DungeonManager is a fairly large class, so we will view it in sections. Open up the DungeonManager for editing. You can see the first section of DungeonManager in Code Snip 4.1:

1 using UnityEngine;
2 using System;
3 using System.Collections.Generic;
4 using Random = UnityEngine.Random;
5
6 public enum TileType {
7   essential, random, empty
8 }
9
10 public class DungeonManager : MonoBehaviour {

We are going to need a list, a dictionary, and some ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required