Example #1
0
    public IEnumerator FindSubWordsCoroutine(WordLevel level)
    {
        level.subWords = new List <string>();
        string str;

        List <string> words = WordList.GET_WORDS();

        for (int i = 0; i < WordList.WORD_COUNT; i++)
        {
            str = words[i];
            if (WordLevel.CheckWordInLevel(str, level))
            {
                level.subWords.Add(str);
            }

            if (i % WordList.NUM_TO_PARSE_BEFORE_YIELD == 0)
            {
                yield return(null);
            }
        }

        level.subWords.Sort();
        level.subWords = SortWordsByLength(level.subWords).ToList();

        SubWordSearchComplete();
    }
Example #2
0
    // A coroutine that finds words that can be spelled in this level
    public IEnumerator FindSubWordsCoroutine(WordLevel level)
    {
        level.subWords = new List <string>();
        string str;

        List <string> words = WordList.GET_WORDS();

        // Iterate through all of the words in the wordList
        for (int i = 0; i < WordList.WORD_COUNT; i++)
        {
            str = words[i];
            // Check whether each one can be spelled using level.charDict
            if (WordLevel.CheckWordInLevel(str, level))
            {
                level.subWords.Add(str);
            }
            // Yield if we have parsed a lot of words this frame
            if (i % WordList.NUM_TO_PARSE_BEFORE_YIELD == 0)
            {
                // yield until the next frame
                yield return(null);
            }
        }

        level.subWords.Sort();
        level.subWords = SortWordsByLength(level.subWords).ToList();

        // The coroutine is complete, so call SubWordSearchComplete()
        SubWordSearchComplete();
    }