/// <summary> /// Handles when an available letter is pressed, /// sets that letter and check if accross or down direction the word is completed and correct /// That list of cells will be blocked /// </summary> /// <param name="idLetter">Letter id.</param> public void OnLetterButtonPress(int idLetter) { CellCrossWord selectedCell = m_CrossWordGUI.GetCell(m_LastSelectedRow, m_LastSelectedColumn); if ((selectedCell == null) || selectedCell.IsMarkAsCorrect) { return; } // Set letter in grid string auxLetter = m_CrossWordGUI.GetLetter(idLetter); m_CrossWordGUI.SetLetter(m_LastSelectedRow, m_LastSelectedColumn, auxLetter); // Get accross and down info for this coords in solution grid InfoWordCrossword accrossInfo = m_CrossWordSolution.GetAcrossInfo(m_LastSelectedRow, m_LastSelectedColumn); InfoWordCrossword downInfo = m_CrossWordSolution.GetDownInfo(m_LastSelectedRow, m_LastSelectedColumn); Debug.Log("OnLetterButtonPress selectedCell: " + auxLetter); Debug.Log("OnLetterButtonPress accrossInfo word: " + accrossInfo.Word + " accrossInfo letter: " + accrossInfo.Letter); Debug.Log("OnLetterButtonPress downInfo word: " + downInfo.Word + " downInfo letter: " + downInfo.Letter); // Check accross word info solution with grid if (accrossInfo.Valid) { // Checks if that letter is correct and block if (auxLetter == accrossInfo.Letter.ToString()) { selectedCell.MarkCorrect(m_ColorCorrectWord); } } // Check down word info solution with grid if (downInfo.Valid) { // Checks if that letter is correct and block if (auxLetter == downInfo.Letter.ToString()) { selectedCell.MarkCorrect(m_ColorCorrectWord); } } // Remove hint from list of hints if (auxLetter == m_CrossWordSolution.Letter(m_LastSelectedRow, m_LastSelectedColumn).ToString()) { m_ListCoordHints.Remove(new Vector2(m_LastSelectedRow, m_LastSelectedRow)); } }
public void InitTableboard() { // Fill table board with pieces m_GridBoard = new CellCrossWord[CrossWordGenerator.NRows, CrossWordGenerator.NCols]; int indexPieces = 0; for (int iRow = 0; iRow < CrossWordGenerator.NRows; iRow++) { for (int iCol = 0; iCol < CrossWordGenerator.NCols; iCol++) { CellCrossWord piece = m_ContentCrossWord.GetChild(indexPieces).GetComponent <CellCrossWord>(); m_GridBoard[iRow, iCol] = piece; indexPieces++; } } }