Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
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

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 PRNs for our Dungeon class. Lines 2-4 will enable these things for our use. Lines 6-8 introduces a global enumeration that we will use to keep track of our path types. Then, Line 10 leads us into the DungeonManager definition, starting with a helper...

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
Banner background image