Start me up
Remember that we're building this game with Unity GUI controls. Just as we created a clickable Play Game button on the title screen, we're going to build all of our clickable game cards using the same button control. Our grid of cards will be a grid of GUI buttons aligned on the screen.
Let's add some code to the default Start
function to get the ball rolling. Start
is another one of those built-in Unity functions that gets called before Update
or OnGUI
, so it's a good place to initialize some stuff. Type the following code near the top of your script, beneath the list of variables we just declared:
function Start () { playerCanClick = true; // We should let the player play, don't you think? // Initialize some empty Collections: aCards = new List.<Card>(); // this Generic List is our deck of cards. It can only ever hold instances of the Card class. aGrid = new Card[rows,cols]; // The rows and cols variables help us define the dimensions of this 2D array aCardsFlipped...