While trying to learn more about about arrays I have made a small memory game where the player clicks on books and if they match the books are destroyed, a problem I am having is that the array will always draw an odd number of random books, thus the game can never be completed, I have looked over the documentation and cant find any examples, can anyone offer advice as to how to create the array that it always draws an even number of random books.
here is my array code.
void Start ()
{
for (int y = 0; y < gridY; y++)
{
for (int x = 0; x < gridX; x++)
{
//Vector3 pos = new Vector3(x, 0, y) * spacing;
int amount = Random.Range(0, books.Length);
Instantiate(books[amount], new Vector3(y * 2 * books[amount].transform.localScale.x * spacing, 10, x * 2 * books[amount].transform.localScale.z * spacing), Quaternion.identity);
}
}
allow = true;
}