Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Procedural Content Generation for Unity Game Development

You're reading from   Procedural Content Generation for Unity Game Development Harness the power of procedural content generation to design unique games with Unity

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher
ISBN-13 9781785287473
Length 260 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ryan Watkins Ryan Watkins
Author Profile Icon Ryan Watkins
Ryan Watkins
Arrow right icon
View More author details
Toc

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 (0, floorTiles.Length)];
73      GameObject instance = Instantiate (toInstantiate, new Vector3 (tileToAdd.x, tileToAdd.y, 0f), Quaternion.identity) as GameObject;
74      instance.transform.SetParent (boardHolder);
75...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime