Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UnityEngine
- import System
- class Card (System.Object):
- public isFaceUp = false
- public isMatched = false
- public img = "robot"
- class GameScript (MonoBehaviour):
- cols = 4
- rows = 4
- totalCards = cols * rows
- matchesToWin = totalCards * 0.5
- cardW = 100
- cardH = 100
- aCards = array(System.Object, cols * rows)
- aGrid = matrix(System.Object, cols, rows)
- aCardsFlipped = array(System.Object, 2)
- playerCanClick as System.Boolean
- playerHasWon = false
- def Start ():
- playerCanClick = true
- for i in range(rows):
- for j in range(cols):
- aGrid[i,j] = Card()
- def BuildGrid ():
- GUILayout.BeginVertical()
- for i in range(rows):
- GUILayout.BeginHorizontal()
- for j in range(cols):
- card = aGrid[i,j]
- if GUILayout.Button( UnityEngine.Resources.Load( card.img ), GUILayout.Width( cardW ) ):
- Debug.Log( card.img )
- GUILayout.EndHorizontal()
- GUILayout.EndVertical()
- def OnGui ():
- GUILayout.BeginArea( Rect( 0, 0, Screen.width, Screen.height))
- BuildGrid()
- GUILayout.EndArea()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement