I’m trying to test this tutorial game on the adroid OS but the tutorial only seems to work on the PC/Web player builds. Now, I beleive my problem lies with my 3 arrays that I have in my script, because Android can’t hand JS GUI arrays, and they need to be changed to C# arrays… (if im understanding it right) SO my question is, how do change them? Im new to scripting and this is a little beyond me right now. I get errors when I try to compile for Android… they say BCE0019 and BCE0048 (‘item’ not a memeber of object and object does not support slicing) Please help! Here is my script…
void OnGUI (){
GUILayout.BeginArea ( new Rect(0,0,Screen.width,Screen.height));
BuildGrid();
if(playerHasWon) BuildWinPrompt();
GUILayout.EndArea();
print("building grid!");
}
int cols = 4;
int rows = 4;
int totalCards = cols*rows;
int matchesNeededToWin = totalCards * 0.50f;
int matchesMade = 0;
int cardW = 100;
int cardH = 100;
Array aCards;
Array aGrid;
ArrayList aCardsFlipped = new ArrayList();
bool playerCanClick;
bool playerHasWon = false;
void BuildGrid (){
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
for(i=0; i<rows; i++)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
for(j=0; j<cols; j++)
{
Object card = aGrid *[j];*
-
string img;* -
if(card.isMatched)* -
{* -
img = "blank";* -
}* -
else* -
if(card.isFaceUp)* -
{* -
img = card.img;* -
}* -
else* -
{* -
img = "wrench";* -
}* -
GUI.enabled = !card.isMatched;* -
if (GUILayout.Button(Resources.Load(img),* -
GUILayout.Height(cardH),GUILayout.Width(cardW)))* -
{* -
if(playerCanClick)* -
{* -
FlipCardFaceUp(card);* -
Debug.Log(card.img);* -
}* -
}* -
GUI.enabled = true;* -
}* -
GUILayout.FlexibleSpace();* -
GUILayout.EndHorizontal();* -
}* -
GUILayout.FlexibleSpace();* -
GUILayout.EndVertical();* -
}* -
void Start (){*
-
playerCanClick = true;* -
string[] aCards;* -
string[] aGrid;* -
aCardsFlipped = new ArrayList();* -
BuildDeck();* -
for(i=0; i<rows; i++)* -
{*
_ aGrid = new ArrayList();_
* for(int j=0; j<cols; j++)*
* {*
* int someNum = Random.Range(0,aCards.length);*
_ aGrid [j] = aCards[someNum];
* aCards.RemoveAt(someNum);
}
}
}*_
* class Card extends System.Object*
* {*
* bool isFaceUp = false;*
* bool isMatched = false;*
* string img;*
* int id;*
* void Card ( string img , int id ){*
* this.img = img;*
* this.id = id;*
* }*
* }*
* void BuildDeck (){*
* int totalRobots = 4;*
* Card card;*
* int id = 0;*
* for(i=0; i<totalRobots; i++)*
* {*
* aRobotParts : string [] = [“Head”, “Arm”, “Leg”];*
* for(j=0; j<2; j++)*
* {*
* int someNum = Random.Range(0, aRobotParts.length);*
* string theMissingPart = aRobotParts[someNum];*
* aRobotParts.RemoveAt(someNum);*
* card = new Card(“robot” + (i+1) + “Missing” + theMissingPart, id);*
* aCards.Add(card);*
* card = new Card(“robot” + (i+1) + theMissingPart,id);*
* aCards.Add(card);*
* id++;*
* }*
* }*
* }*
* void FlipCardFaceUp ( Card card ){*
* card.isFaceUp = true;*
* if(aCardsFlipped.IndexOf(card) < 0)*
* {*
* aCardsFlipped.Add(card);*
* if(aCardsFlipped.Count == 2)*
* {*
* playerCanClick = false;*
* yield return new WaitForSeconds(1);*
* if(aCardsFlipped[0].id == aCardsFlipped[1].id)*
* {*
* //MATCH!*
* aCardsFlipped[0].isMatched = true;*
* aCardsFlipped[1].isMatched = true;*
* matchesMade ++;*
* if(matchesMade >= matchesNeededToWin)*
* {*
* playerHasWon = true;*
* } *
* }*
* else*
* {*
* aCardsFlipped[0].isFaceUp = false;*
* aCardsFlipped[1].isFaceUp = false;*
* }*
* aCardsFlipped = new ArrayList();*
* playerCanClick = true;*
* }*
* }*
* }*
* void BuildWinPrompt (){*
* int winPromptW = 100;*
* int winPromptH = 90;*
* float halfScreenW = Screen.width/2;*
* float halfScreenH = Screen.height/2;*
* int halfPromptW = winPromptW/2;*
* int halfPromptH = winPromptH/2;*
* GUI.BeginGroup( new Rect(halfScreenW-halfPromptW,halfScreenH-halfPromptH,*
* winPromptW, winPromptH));*
* GUI.Box ( new Rect(0,0,winPromptW,winPromptH),*
* “YOU WIN!”);*
* if(GUI.Button( new Rect(10,40,80,20), “Play Again?”))*
* {*
* Application.LoadLevel(“Title”);*