private void BoardSetup() { m_board = new Candy[m_horizontalSize, m_verticalSize]; for (int i = 0; i < m_horizontalSize; i++) { for (int j = 0; j < m_verticalSize; j++) { //******Check the possible colors to add to the board List <int> possibleColors = new List <int>(); possibleColors.AddRange(Enumerable.Range(0, m_candyPrefabs.Count())); if (i >= 2) { if (m_board[i - 1, j].m_color == m_board[i - 2, j].m_color) { possibleColors.Remove((int)m_board[i - 1, j].m_color); } } if (j >= 2) { if (m_board[i, j - 1].m_color == m_board[i, j - 2].m_color) { possibleColors.Remove((int)m_board[i, j - 1].m_color); } } //******Candy Assignement Candy prefabToInstantiate = m_candyPrefabsDictonary[(CandyColor)possibleColors[Random.Range(0, possibleColors.Count)]][RandomCandyTypeIndex()]; Candy candy = InstatiateCandyAtPosition(prefabToInstantiate, m_startSpawnPosition + new Vector2(i * m_distanceUnits, j * m_distanceUnits)); candy.SetUpPosition(new Vector2Int(i, j)); m_board[i, j] = candy; } } }