コード例 #1
0
        /// <summary>
        /// Tries to get the question in down direction if there is an actual word according to the given coord
        /// </summary>
        /// <returns>Returns wheter it was succes or not</returns>
        /// <param name="_iRow">Row to check</param>
        /// <param name="_iCol">Col to check</param>

        /*/// <param name="_iRowStart">Output row for the word</param>
         * /// <param name="_iColStart">Output col for the word</param>
         * /// <param name="_question">Question for that word</param>
         * /// <param name="_word">Word for that question</param>*/
        public InfoWordCrossword GetDownInfo(int iRow, int iCol /*, out  int _iRowStart, out int _iColStart, out string _question,out string _word*/)
        {
            // Piece

            /*_iColStart = iCol;
             *          _question = "";
             *          _word = "";*/

            InfoWordCrossword infoDown = new InfoWordCrossword();

            // Set the correct letter
            infoDown.Valid = false;

            infoDown.StartCol = iCol;


            // Find first down position
            int auxIRow = iRow;

            for (int i = auxIRow; i >= 0; i--)
            {
                if (grid[i, iCol] == EMPTYCHARACTER)
                {
                    auxIRow = i + 1;
                    break;
                }

                if ((i == 0) && (grid[i, iCol] != EMPTYCHARACTER))
                {
                    auxIRow = i;
                }
            }

            infoDown.StartRow = auxIRow;
            //_iRowStart = auxIRow;
            // Gets word to check in list
            string word = "";

            for (int i = auxIRow; i < NRows; i++)
            {
                if (grid[i, iCol] != EMPTYCHARACTER)
                {
                    word += grid[i, iCol];
                }
                else
                {
                    break;
                }
            }

            if (word != "")
            {
                // Find word in list words
                for (int i = 0; i < listSingleWords.Count; i++)
                {
                    // Get the original word without index word
                    string auxWord = listSingleWords[i].Answer;
                    if (auxWord == word)
                    {
                        infoDown.Question = listSingleWords[i].Questions;
                        infoDown.Word     = listSingleWords[i].Answer;
                        infoDown.Letter   = grid[iRow, iCol];
                        infoDown.Valid    = true;
                    }
                }
            }
            return(infoDown);
        }
コード例 #2
0
        /// <summary>
        /// Tries to get the question in across coord if there is an actual word according to the given coord
        /// </summary>
        /// <returns>Returns WordCell with a valid answer</returns>
        /// <param name="_iRow">Row to check</param>
        /// <param name="_iCol">Col to check</param>

        public InfoWordCrossword GetAcrossInfo(int iRow, int iCol)
        {
            InfoWordCrossword infoAcross = new InfoWordCrossword();

            // Set the correct letter
            infoAcross.Valid    = false;
            infoAcross.StartRow = iRow;

            // Find the first column until is an empty character
            int auxICol = iCol;

            for (int i = auxICol; i >= 0; i--)
            {
                if (grid[iRow, i] == EMPTYCHARACTER)
                {
                    auxICol = i + 1;
                    break;
                }

                if ((i == 0) && (grid[iRow, i] != EMPTYCHARACTER))
                {
                    auxICol = i;
                }
            }
            infoAcross.StartCol = auxICol;

            // Gets word to check in list
            string word = "";

            for (int i = auxICol; i < NCols; i++)
            {
                if (grid[iRow, i] != EMPTYCHARACTER)
                {
                    word += grid[iRow, i];
                }
                else
                {
                    break;
                }
            }

            if (word != "")
            {
                // Find word in list words
                for (int i = 0; i < listSingleWords.Count; i++)
                {
                    // Get the original word without index word
                    string auxWord = listSingleWords[i].Answer;
                    if (auxWord == word)
                    {
                        //_question = this.listSingleWords[i].Questions;
                        //_word = this.listSingleWords[i].Answer;

                        infoAcross.Question = listSingleWords[i].Questions;
                        infoAcross.Word     = listSingleWords[i].Answer;
                        infoAcross.Letter   = grid[iRow, iCol];
                        infoAcross.Valid    = true;
                    }
                }
            }
            return(infoAcross);
        }