public void LoadWord(SearchData data) { InitColor(); wordPositon = data.wordPositon; wordRow = wordPositon.Count; wordCol = wordPositon[0].Count; Calculate(wordRow, wordCol); for (int i = 0; i < wordRow; i++) { List <string> word = wordPositon[i]; for (int j = 0; j < wordCol; j++) { RectTransform item; if (i == 0 && j == 0) { item = cell; } else { item = Instantiate(cell, wordGroup.transform); item.SetSiblingIndex(i * wordCol + j); } SearchCell search_cell = item.GetComponent <SearchCell> (); search_cell.SetText(word[j].Substring(0, 1), scale, i, j); item.name = "Search" + i.ToString() + j.ToString(); item.anchoredPosition = new Vector3(cell.anchoredPosition.x + j * min, cell.anchoredPosition.y - i * min); item.gameObject.SetActive(true); if (word[j].Length > 1) { if (hintInital.Count != 0 && hintInital.Contains(i * wordCol + j)) { search_cell.ChangeBgColor(Color.red); } else { inital.Add(search_cell); } } } } float moveX = areaWidth - wordCol * min; float moveY = areaHeight - wordRow * min; wordGroup.anchoredPosition = new Vector2(wordGroup.anchoredPosition.x + moveX / 2, wordGroup.anchoredPosition.y - moveY / 2); SearchController.instance.drawer.SetColor(colors[rightCount]); SearchController.instance.drawer.SetWidth(min); ShowAnswerWord(data.answer); }
public bool CheckAnswer(SearchCell begin, SearchCell end) { if (begin == end) { return(false); } bool isRight = false; string word = SetAnswer(begin.pos, end.pos); for (int i = 0; i < answer.Count; i++) { if (answer[i].word.text.ToLower() == word.ToLower()) { AddLinePos(begin.pos, end.pos, word.ToLower()); isRight = true; answer[i].Done(colors[rightCount]); answer.RemoveAt(i); SearchCell sc = SearchController.instance.drawer.beginCell; if (inital.Contains(sc)) { inital.Remove(sc); } sc.ChangeBgColor(Color.white); rightCount++; SearchController.instance.drawer.SetColor(colors[rightCount]); CheckGameComplete(); break; } } if (isRight) { combCount++; Compliment.Instance.ShowRandom(combCount); } else { combCount = 0; } return(isRight); }