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 O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.