Tell the game you have all possible matches

Hi,

I work on a card game where you have to match several tiles to others.

To compare if something matches i have a small function on all cards.
The problem is, i don’t know how can i check the game is won, when all possible tiles match with each other.

public void CheckColors()
	{
		//if there is anything on the top of this card && the top cards bottom is matching this top
		if(ccTop != null && ccTop.Bottom == Top && ccTop.formBottom != formTop)
		{
			//color match
			Debug.Log ("Colors and Form are matching in the top");
		}

		if(ccRight != null && ccRight.Left == Right && ccRight.formLeft != formRight)
		{
			//color match
			Debug.Log ("Colors and Form are matching in the right");
		}

		if (ccBottom != null && ccBottom.Top == Bottom && ccBottom.formTop != formBottom)
		{
			//color match
			Debug.Log ("Colors and Form are matching in the bottom");
		}

		if (ccLeft != null && ccLeft.Right == Left && ccLeft.formRight != formLeft)
		{
			//color match
			Debug.Log ("Colors and Form are matching in the left");
		}
	}

Since i can move around tiles and also rotate them, i would like to know how can i tell the game i have all possible matches?

56933-cards.png

The matching works already.

56961-cardswin.png

If i understand correctly you just need to make your own way to store running game “data” in public variables that u can use.

I see you have only 4 possible “color match” checking so
First of all, i hope you are calling that CheckColors() in a user input basis and not on a Update because you just don’t need to, if you are, just checkColor when you know the user makes a move ;“input” for example.

So, you have alot of possibilities here to check if all of the “colors match” at the same time, right now you are doing a separate check, problably u dont even need to check in a order either?, lets say something like this ; “pseudo code”

int count = 0; //reset to 0 each time u check

if(top is correct){
    count++;
}
///\ repeat that for every condition

//Then :
if (count == 4){
    //Player Won!   <-- set a public bool or something to tell other scripts.
}