Example #1
0
    private ClimateWord findAUniqueWord()
    {
        ClimateWord uniqueWord = Dictionary.instance.next(0);

        while (this.isPlayed(uniqueWord) == true)
        {
            uniqueWord = Dictionary.instance.next(0);
        }

        return(uniqueWord);
    }
Example #2
0
    private void setword(ClimateWord climateWord)
    {
        playedWords[indexPlayedWords] = climateWord;
        string word = climateWord.word;

        word                 = word.ToUpper();
        this.word            = word;
        this.hint            = climateWord.meaning;
        revealed             = new char[word.Length];
        lettesIndicator.text = "Letters: " + word.Length;
        Debug.Log(word);
        updatewordIndicator();
    }
Example #3
0
    private bool isPlayed(ClimateWord word)
    {
        for (int i = 0; i < indexPlayedWords; i++)
        {
            ClimateWord currentWord = playedWords[i];
            if (currentWord.word == word.word)
            {
                return(true);
            }
        }

        return(false);
    }
Example #4
0
    public static Dictionary load()
    {
        if (s_instance != null)
        {
            return(s_instance);
        }


        HashSet <ClimateWord> wordList = new HashSet <ClimateWord> ();
        //loading word list
        TextAsset  asset = Resources.Load("words") as TextAsset;
        TextReader src   = new StringReader(asset.text);

        //reading lines
        while (src.Peek() != -1)
        {
            string fullword = src.ReadLine();
            int    equalPos = fullword.IndexOf("=");

            string word        = fullword;
            string description = "";
            if (equalPos > 0)
            {
                word        = fullword.Substring(0, equalPos);
                word        = word.Replace(" ", "");
                description = fullword.Substring(equalPos + 1);
            }

            if (isWordOK(word))
            {
                //wordList.Add(word);

                ClimateWord newWord = new ClimateWord();
                newWord.word    = word;
                newWord.meaning = description.Trim();
                wordList.Add(newWord);
            }
        }
        //unloading assets
        Resources.UnloadAsset(asset);
        //setup dict
        ClimateWord[] words = new ClimateWord[wordList.Count];
        wordList.CopyTo(words);
        s_instance = new Dictionary(words);

        return(s_instance);
    }