I am currently working on the 2D Roguelike Tutorial from Unity’s learn page, but I’m afraid that I’ve run into some confusion. Below is my script:
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using Random = UnityEngine.Random;
public class BoardManager : MonoBehaviour
{
[Serializable]
public class Count
{
public int minimum;
public int maximum;
// Used to assign defualt values
public Count (int min, int max)
{
minimum = min;
maximum = max;
}
}
// Defines dimensions of game board (8x8)
public int columns = 8;
public int rows = 8;
// Defines a random range of which the amount of walls/food that will spawn
public Count wallCount = new Count(5, 9);
public Count foodCount = new Count(1, 5);
public GameObject exit;
// Defines an array in which one out of the total items will be spawned
public GameObject[] floorTiles
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
The issue that I’m having so far is that the class Count contains a variable and constructor, however, you will see references to the class in the data type of public variables wallCount and foodCount. For future reference, why are these variables not included in the class? If I were writing my own classes, what types of data should I include in it and what should I not include?