I am trying to make a Sudoku game in Unity3D but I'm currently stuck on the logic behind the game. (
checking if all the numbers in the same subgrid, row and column are different)
I have been able to get a script that generates the whole grid running, both for a 2x2, 2x3 and a 3x3 level. The part that I am stuck on is making the 2D Array to hold the selected values for all subgrids. I can also provide the full GenerateGrid script if it's needed, but any help apart from that would be of help.
Here is also a small sample of the GenerateGrid script - the method that defines the whole grid's size depending on the difficulty:
void GetDifficulty()
{
switch (difficulty)
{
case Difficulty.Easy:
gridSize = 4;
FindObjectOfType<AudioManager>().Play("BGM_Level_Easy");
cam.transform.position = new Vector3(-2.5f, (float)gridSize * 10, ((float)gridSize / 2 - 0.5f) * 10);
break;
case Difficulty.Medium:
gridSize = 6;
FindObjectOfType<AudioManager>().Play("BGM_Level_Medium");
cam.transform.position = new Vector3(-1f, (float)gridSize * 10, ((float)gridSize / 2 - 0.5f) * 10);
break;
case Difficulty.Hard:
gridSize = 9;
FindObjectOfType<AudioManager>().Play("BGM_Level_Hard");
cam.transform.position = new Vector3(2f, (float)gridSize * 10, ((float)gridSize / 2 - 0.5f) * 10);
break;
default:
gridSize = 6;
FindObjectOfType<AudioManager>().Play("BGM_Level_Medium");
cam.transform.position = new Vector3(-1f, (float)gridSize * 10, ((float)gridSize / 2 - 0.5f) * 10);
break;
}
Debug.Log(difficulty);
(
Note: I have tried my best to research as much as I can about this, but none of the stuff I found online was about a Unity3D version of the game, only 2D ones)
Thanks!
What I have tried:
I have tried making the code manually compare each tile in the subgrid to each other tile, but it didn't work - only printed that it did. (apart from being really unoptimized)