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

BoardManager

The BoardManager class already keeps references to the floor and wall tiles. Rather than having our DungeonManager class keep the same references, we will send our dungeon dictionary to the BoardManager class and have it build the Dungeon Board. We will need to update our BoardManager class for this. Open up BoardManager.cs for editing and make the changes seen in Code Snip 4.7:

29 public GameObject exit;
…
33 public GameObject[] outerWallTiles;
… 
40 private Transform dungeonBoardHolder;
41 private Dictionary<Vector2, Vector2> dungeonGridPositions; … 69 private void addTiles(Vector2 tileToAdd) { 70 if (!gridPositions.ContainsKey (tileToAdd)) { 71 gridPositions.Add (tileToAdd, tileToAdd); 72 GameObject toInstantiate = floorTiles [Random.Range ...

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