// Use this for initialization void Start() { score = 0; timeSinceLastGem = 0.0f; marbles = new List <Marble>(); tileFolder = new GameObject(); tileFolder.name = "Tiles"; marbleFolder = new GameObject(); marbleFolder.name = "Marbles"; board = new Tile [boardWidth, boardHeight]; List <int> openColumns = new List <int>(); for (int i = 0; i < 3; i++) { addMarble(); } for (int i = 0; i < boardWidth; i++) { openColumns.Add(i); } for (int i = 0; i < boardWidth; i++) { for (int j = 0; j < boardHeight; j++) { board[i, j] = addTile(i - boardWidth / 2, j - boardHeight / 2); int rand = Random.Range(0, 5); if (rand == 0) { board[i, j].addTurn(Random.Range(0, 4)); } } } for (int row = 0; row < boardHeight; row++) { int colIndex = Random.Range(0, openColumns.Count); int col = openColumns[colIndex]; board[row, col].addTurn(Random.Range(0, 4)); openColumns.RemoveAt(colIndex); } GameObject gemManagerObject = GameObject.CreatePrimitive(PrimitiveType.Quad); gemMan = gemManagerObject.AddComponent <GemManager>(); gemMan.init(this, board); GameObject elManObject = GameObject.CreatePrimitive(PrimitiveType.Quad); elMan = elManObject.AddComponent <ElephantManager>(); elMan.init(this); foreach (Marble t in marbles) { t.init(this); } }
// Use this for initialization void Start() { score = 0; timeSinceLastGem = 0.0f; marbles = new List<Marble>(); tileFolder = new GameObject(); tileFolder.name = "Tiles"; marbleFolder = new GameObject(); marbleFolder.name = "Marbles"; board = new Tile [boardWidth, boardHeight]; List<int> openColumns = new List<int>(); for (int i = 0; i < 3; i++) { addMarble(); } for (int i = 0; i < boardWidth; i++) { openColumns.Add(i); } for (int i = 0; i < boardWidth; i++) { for (int j = 0; j < boardHeight; j++) { board[i, j] = addTile(i - boardWidth / 2, j - boardHeight / 2); int rand = Random.Range(0, 5); if (rand == 0) { board[i, j].addTurn(Random.Range(0, 4)); } } } for (int row = 0; row < boardHeight; row++) { int colIndex = Random.Range(0, openColumns.Count); int col = openColumns[colIndex]; board[row, col].addTurn(Random.Range(0, 4)); openColumns.RemoveAt(colIndex); } GameObject gemManagerObject = GameObject.CreatePrimitive(PrimitiveType.Quad); gemMan = gemManagerObject.AddComponent<GemManager>(); gemMan.init(this, board); GameObject elManObject = GameObject.CreatePrimitive(PrimitiveType.Quad); elMan = elManObject.AddComponent<ElephantManager>(); elMan.init(this); foreach (Marble t in marbles) { t.init(this); } }