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 CWword(string word, int x, int y, Direction dir) { _x = x; _y = y; _direction = dir; _word = word; }
/// <summary> /// Opens the word starting from [x,y] cell to the end. /// </summary> /// <param name="x">X of the first cell of a word in a grid.</param> /// <param name="y">Y of the first cell of a word in a grid.</param> /// <param name="direction">Tells whether to open vertically or horizontally.</param> public void OpenWord(int x, int y, CWword.Direction direction) { Debug.Log("Opening word at " + x + ", " + y); CWCell nextCell = _cells[x, y]; while (nextCell != null) { nextCell.OpenLetter(); if (direction == CWword.Direction.vertical) { if (++x > _cells.GetUpperBound(0)) { break; } } else { if (++y > _cells.GetUpperBound(1)) { break; } } nextCell = _cells[x, y]; Debug.Log("Next cell (" + x + ", " + y + ") is null: " + (nextCell == null)); if (null != nextCell) { Debug.Log("Letter is " + nextCell.GetHiddenLetter()); } } }
/// <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(); } }