A GridManager class handles the 2D grid representation for the world map. We keep it as a singleton instance of the GridManager class, as we only need one object to represent the map. A singleton is a programming pattern that restricts the instantiation of a class to one object and, therefore, it makes the instance easily accessible from any point of the application. The steps to set up the GridManager are as follows:
- The code for setting up the GridManager is shown in the following GridManager.cs file:
using UnityEngine; using System.Collections; public class GridManager : MonoBehaviour { private static GridManager s_Instance = null; public static GridManager instance { get { if (s_Instance == null) { s_Instance ...