September 2010
Beginner
384 pages
8h 49m
English
Our matchesMade, matchesNeededToWin, and playerHasWon variables have been standing at the ready this whole time. Let's finally make use of them.
FlipCardFaceUp function, where you're detecting a match:if(aCardsFlipped[0].id == aCardsFlipped[1].id)
{
// Match!
aCardsFlipped[0].isMatched = true;
aCardsFlipped[1].isMatched = true;
matchesMade ++;
if(matchesMade >= matchesNeededToWin)
{
playerHasWon = true;
}
OnGUI function:function OnGUI () {
GUILayout.BeginArea (Rect (0,0,Screen.width,Screen.height));
GUILayout.BeginHorizontal();
BuildGrid();
if(playerHasWon) BuildWinPrompt();
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
Read now
Unlock full access