So, If I understand you correctly, this is a solution:
I made two classes, one attached to every card and one attached to an empty game object (will handle input and progression) maybe this is not giving you exactly the result you want, but I do hope that it will point you to the right direction. First up, the card class: (There is absolutely no need at all to use different codes for each card. This coding practice will in time make you want to find the highest manmade building in the world and jump from it while screaming “AWMAGAD SO MANY SCRIPTS”. We want to avoid that by creating a simple class for the cards (Note that both the class scripts are summarized without all the commenting at the bottom of the answer):
public class Card : MonoBehaviour
{
//Here, only two fields are necessary. These are then set in the inspector.
//The number of the card (which is the correct button to press) and the position
//of the card (1 = first card, 2 = second card and so on...)
public int cardNumber;
public int cardPosition;
}
Now, this class can be assigned to all the cards on the board. And then in the inspector you can set the field values:
Then the class for the game object, handling input and progression:
public class Game : MonoBehaviour
{
//Now, in this game class we need to store references to our
//cards, one way to achieve this is to create an array of the Card-class
//we created as such:
public Card[] cards;
//We also need to know which position we are at now
public int currentPosition;
//Next up, the method for checking for the next card: I will call it
//CheckForCard and I will pass an integer to it. That is what number
//we think it have:
public void CheckForCard(int number)
{
//Now we have both the numbers we need, we need to see if they're correct
//We do this by iterating through our card array, using a foreach loop. This
//will run once per member of the array:
foreach(Card card in cards)
{
//The first to check is if the card the loop is currently checking is
//at the correct position, if not, then we need to check the next card
//in the array
if(card.cardPosition == currentPosition)
{
//If the card position in this array is at the position we are now
//checking for, we also need to check if the number is correct! That is when
//we use our passed integer!
if(card.cardNumber == number)
{
//CORRECT, now, move to the next position and stop the loop.
currentPosition++;
return;
}
else
{
//INCORRECT. Stop the loop and wait for a new input
return;
}
}
}
}
//In the update, we check for input:
void Update()
{
if(Input.GetKeyDown(KeyCode.Alpha1))
{
CheckForCard(1);
}
if(Input.GetKeyDown(KeyCode.Alpha2))
{
CheckForCard(2);
}
if(Input.GetKeyDown(KeyCode.Alpha3))
{
CheckForCard(3);
}
if(Input.GetKeyDown(KeyCode.Alpha4))
{
CheckForCard(4);
}
if(Input.GetKeyDown(KeyCode.Alpha5))
{
CheckForCard(5);
}
if(Input.GetKeyDown(KeyCode.Alpha6))
{
CheckForCard(6);
}
if(Input.GetKeyDown(KeyCode.Alpha7))
{
CheckForCard(7);
}
if(Input.GetKeyDown(KeyCode.Alpha8))
{
CheckForCard(8);
}
if(Input.GetKeyDown(KeyCode.Alpha9))
{
CheckForCard(9);
}
}
}
Then assign this game script to an object and use the inspector to drag each card into the array:
Summary; both classes without disturbing comments:
public class Card : MonoBehaviour
{
public int cardNumber;
public int cardPosition;
}
public class Game : MonoBehaviour
{
public Card[] cards;
public int currentPosition;
public void CheckForCard(int number)
{
foreach(Card card in cards)
{
if(card.cardPosition == currentPosition)
{
if(card.cardNumber == number)
{
currentPosition++;
return;
}
else
{
return;
}
}
}
}
void Update()
{
if(Input.GetKeyDown(KeyCode.Alpha1))
{
CheckForCard(1);
}
if(Input.GetKeyDown(KeyCode.Alpha2))
{
CheckForCard(2);
}
if(Input.GetKeyDown(KeyCode.Alpha3))
{
CheckForCard(3);
}
if(Input.GetKeyDown(KeyCode.Alpha4))
{
CheckForCard(4);
}
if(Input.GetKeyDown(KeyCode.Alpha5))
{
CheckForCard(5);
}
if(Input.GetKeyDown(KeyCode.Alpha6))
{
CheckForCard(6);
}
if(Input.GetKeyDown(KeyCode.Alpha7))
{
CheckForCard(7);
}
if(Input.GetKeyDown(KeyCode.Alpha8))
{
CheckForCard(8);
}
if(Input.GetKeyDown(KeyCode.Alpha9))
{
CheckForCard(9);
}
}
}