C# Addendum

Let's see what it takes to convert this script from Unity JavaScript to C#. The complete C# script is shown in the following code snippet:

using UnityEngine; using System.Collections; using System.Collections.Generic; public class GameScriptCSharp : MonoBehaviour { private int cols = 4; // the number of columns in the card grid private int rows = 4; // the number of rows in the card grid private int totalCards = 16; private int matchesNeededToWin; private int matchesMade = 0; // At the outset, the player has not made any matches private int cardW = 100; // Each card's width and height is 100 pixels private int cardH = 100; private List<Card> aCards; // We'll store all the cards we create in this array private Card[,] aGrid; // This ...

Get Unity 4.x Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.