B
B
BeLikeaJJ2020-09-16 15:14:51
C++ / C#
BeLikeaJJ, 2020-09-16 15:14:51

Throws an error:ArgumentOutOfRangeException...WordGame.HighLightWyrd (WordGame.cs:311) WordGame.CheckWord () (WordGame.cs:283)?

public void CheckWord()
    {
        string subWord;
        bool foundTestWord = false;
        List<int> containedWords = new List<int>();
        for (int i = 0; i < currLevel.subWords.Count; i++)
        {
           
            subWord = currLevel.subWords[i];
            if (testWord.Equals(subWord))
            {
                HighLightWyrd(i);
                Score_manager.SCORE(wyrds[i], 1);
                foundTestWord = true;
            }
            else if(testWord.Contains(subWord))
            {
                containedWords.Add(i);
            }
        }
        if (foundTestWord)
        {
            int numContained = containedWords.Count;
            int ndx;
            for (int i = 0; i < containedWords.Count; i++)
            {
                ndx = numContained - i - 1;
                HighLightWyrd(containedWords[ndx]);
                Score_manager.SCORE(wyrds[containedWords[ndx]], i + 2);
            }

        }
        ClearBigLettersActive();           
    }
    void HighLightWyrd(int ndx)
    {
        wyrds[ndx].found = true;
        wyrds[ndx].color = (wyrds[ndx].color + Color.white) / 2f;
        wyrds[ndx].visible = true;
    }
    void ClearBigLettersActive()
    {
        testWord = "";
        foreach(Letter ltr in bigLettersActive)
        {
            bigLetters.Add(ltr);
            ltr.color = bigColorDim;
        }
        bigLettersActive.Clear();
        ArrangeBigLetters();
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question