void Awake() { //Enforce singelton pattern, so there will always only ever be one GameManager //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } else if (instance != this) //If instance already exists and it's not this: { //Then destroy this. This enforces singleton pattern Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); cells = new WorldModeCell[WorldModeGridManager.instance.getColCount()][]; for (int i = 0; i < cells.Length; i++) { cells[i] = new WorldModeCell[WorldModeGridManager.instance.getRowCount()]; } }
private void Start() { liveCount = GameObject.Find("WMLiveCellCount"); genCount = GameObject.Find("WMGenerationCount"); eventSys = GameObject.Find("EventSystem").GetComponent <EventSystem>(); cells = new WorldModeCell[WorldModeGridManager.instance.getColCount()][]; for (int i = 0; i < cells.Length; i++) { cells[i] = new WorldModeCell[WorldModeGridManager.instance.getRowCount()]; } WorldModeGridManager.instance.InitGrid(); if (WorldModeCellManager.instance == null) { //Instantiate gameManager prefab if none exists Instantiate(cellManager); } for (int x = 0; x < WorldModeCellManager.instance.getCellArray().Length; x++) { for (int y = 0; y < WorldModeCellManager.instance.getCellArray()[x].Length; y++) { cells[x][y].CreateNeighborhood(); } } generationCount = 0; Time.timeScale = 0f; }
public void AddCellToArray(WorldModeCell c, int x, int y) { cells[x][y] = c; }