/* * void FillRandomTile() * { * Debug.Log("fill random tile"); * ResetWaitTime(); * * //fill a random tile with its correct letter * TileLogic[] tiles = gameLogic.GetTiles(); * string[] userGrid = gameLogic.GetUserGrid(); * * Dictionary<int, string> emptyTiles = new Dictionary<int, string>(); * * int startIndex = Random.Range(0, tiles.Length - 1); * for(int i = 0; i < tiles.Length; i++) * { * int index = (startIndex + i) % tiles.Length; * TileLogic t = tiles[index]; * if (t == null) * continue; * * if (t.tileLetter != userGrid[index]) * { * emptyTiles.Add(index, t.tileLetter); * //gameLogic.SetRandomTile(t.tileLetter, index); * //break; * } * } * * List<int> keys = new List<int>(emptyTiles.Keys); * * if(keys.Count > 0) * { * * int r = Random.Range(0, keys.Count); * int ind = keys[r]; * gameLogic.SetRandomTile(emptyTiles[ind], ind); * } * * }*/ void FillRandomTileNew() { ResetWaitTime(); string[] userGrid = gameLogic.GetUserGrid(); for (int i = 0; i < tileFillOrder.Length; i++) { TileLogic tl = tileFillOrder[i]; if (tl == null) { continue; } if (tl.tileLetter != userGrid[tl.index]) { gameLogic.SetRandomTile(tl.tileLetter, tl.index); break; } } }