private void FillCWdict(string str, CWword.Direction dir) { int j = 0; int x = 0; int y = 0; int k = 0; while (str[k] != '!') { StringBuilder word = new StringBuilder(); while (str[j] != '(') { word.Append(str[j]); j++; } x = str[j + 1] - '0'; y = str[j + 3] - '0'; j += 5; Debug.Log("word = " + word + " x =" + x + " y =" + y); CWword CWword = new CWword(word.ToString(), x, y, dir); CWdict.Add(word.ToString(), CWword); k = j; FillCrosswordTable(CWword); //Dictionary<string, CWword>.Enumerator i = CWdict.GetEnumerator(); //CWword obj = null; //Debug.Log("SDFSDFDSFS" + ((CWword)CWdict.Values).word); //i.MoveNext(); } }
public Crossword(char[] letters, string[] words, CWword.Direction[] dirs, int[] x, int[] y) { _letters = letters; _words = words; CWdict = new Dictionary <string, CWword>(new StringComparer()); for (int i = 0; i < words.Length; i++) { CWword word = new CWword(words[i], x[i], y[i], dirs[i]); CWdict.Add(words[i], word); } }
/// <summary> /// Also tells if the crossword is finished /// </summary> /// <param name="word"></param> /// <param name="SpellEffect"></param> private void OnWordActivation(string word, SpellEffect SpellEffect) { CWword cwWord = _curCrossword.GetCWword(word); int x = cwWord.x; int y = cwWord.y; CWword.Direction dir = cwWord.direction; _grid.OpenWord(x, y, dir); ++_wordsFound; if (_curCrossword.CWdict.Count == _wordsFound) { OnCrosswordFinished(); } }
private void FillCrosswordTable(CWword cWword) { int i = 0; for (i = 0; i < cWword.word.Length; i++) { if (cWword.direction == CWword.Direction.vertical) { _crosswordTable[cWword.x + i, cWword.y] = cWword.word[i]; } else if (cWword.direction == CWword.Direction.horizontal) { _crosswordTable[cWword.x, cWword.y + i] = cWword.word[i]; } } }