Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BOO 1.04 KB | None | 0 0
  1. import UnityEngine
  2. import System
  3.  
  4. class Card (System.Object):
  5.     public isFaceUp = false
  6.     public isMatched = false
  7.     public img = "robot"
  8.  
  9.  
  10. class GameScript (MonoBehaviour):
  11.     cols = 4
  12.     rows = 4
  13.     totalCards = cols * rows
  14.     matchesToWin = totalCards * 0.5
  15.     cardW = 100
  16.     cardH = 100
  17.     aCards = array(System.Object, cols * rows)
  18.     aGrid = matrix(System.Object, cols, rows)
  19.     aCardsFlipped = array(System.Object, 2)
  20.     playerCanClick as System.Boolean
  21.     playerHasWon = false
  22.  
  23.     def Start ():
  24.         playerCanClick = true
  25.         for i in range(rows):
  26.             for j in range(cols):
  27.                 aGrid[i,j] = Card()
  28.  
  29.     def BuildGrid ():
  30.         GUILayout.BeginVertical()
  31.         for i in range(rows):
  32.        
  33.             GUILayout.BeginHorizontal()
  34.             for j in range(cols):
  35.            
  36.                 card = aGrid[i,j]
  37.                 if GUILayout.Button( UnityEngine.Resources.Load( card.img ), GUILayout.Width( cardW ) ):
  38.                     Debug.Log( card.img )
  39.        
  40.             GUILayout.EndHorizontal()
  41.         GUILayout.EndVertical()
  42.  
  43.     def OnGui ():
  44.         GUILayout.BeginArea( Rect( 0, 0, Screen.width, Screen.height))
  45.         BuildGrid()
  46.         GUILayout.EndArea()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement