We will comprise everything in just a class that will handle the abstract representation, called DSFDungeon:
- Define the DFSDungeon component and its member values:
using UnityEngine;using System.Collections.Generic;public class DFSDungeon : MonoBehaviour{ public int width; public int height; public bool[,] dungeon; public bool[,] visited; private Stack<Vector2> stack; private Vector2 current; private int size; // next steps}
- Define the initialization function:
private void Init(){ // next steps }
- Initialize the required variables and random initial position:
stack = new Stack<Vector2>();size = width * height;dungeon = new bool[height, width];visited = new bool[height, width];current.x = Random.Range(0, width - 1);current.y ...