private void GenerateLetters()
    {
        Letters = new List <KeyValuePair <int, char[]> >();

        for (int i = System.Convert.ToInt32('A'); i <= System.Convert.ToInt32('Z'); ++i)
        {
            for (int j = System.Convert.ToInt32('A'); j <= System.Convert.ToInt32('Z'); ++j)
            {
                for (int k = System.Convert.ToInt32('A'); k <= System.Convert.ToInt32('Z'); ++k)
                {
                    Word word = new Word((char)i, (char)j, (char)k);

                    int matchCount = dictData.GetMatchingWords(word).Count;
                    if (matchCount > 0)
                    {
                        Letters.Add(new KeyValuePair <int, char[]>(matchCount, new char[] { (char)i, (char)j, (char)k }));
                    }
                }
            }
        }

        Letters.Sort(comparer);

        List <string> linesList = new List <string>();

        foreach (var letter in Letters)
        {
            linesList.Add(letter.Value[0].ToString() + '\t' + letter.Value[1].ToString() + '\t' + letter.Value[2].ToString() + '\t' + letter.Key.ToString());
        }

        File.WriteAllLines(path, linesList.ToArray());
        Debug.Log("Challenge Letters Written To File");
    }
Beispiel #2
0
    /// <summary>
    /// Setup for new round
    /// </summary>
    private void Setup()
    {
        paused = false;

        switch (gameMode)
        {
        case GameMode.Classic:
#if UNITY_IOS || UNITY_ANDROID
            if (!adRewarded)
            {
                timeLeft = 61;
                GenerateLetters();
            }
            else
            {
                timeLeft = 31;
            }
#else
            timeLeft = 60;
            GenerateLetters();
#endif
            break;

        case GameMode.TimeTrial:
#if UNITY_IOS || UNITY_ANDROID
            if (!adRewarded)
            {
                timeLeft = 61;
                GenerateLetters();
            }
            else
            {
                timeLeft = 31;
            }
#else
            timeLeft = 60;
#endif
            break;

        case GameMode.Challenge:
            // Gather the letters and time from challenge info and set the states accordingly
            letters             = challengeInfo.Letters;
            timeLeft            = challengeInfo.Time;
            word                = new Word(challengeInfo.Letters[0], challengeInfo.Letters[1], challengeInfo.Letters[2]);
            word.MatchingWords  = dictData.GetMatchingWords(word);
            lettersText[0].text = word.A.ToString();
            lettersText[1].text = word.B.ToString();
            lettersText[2].text = word.C.ToString();
            break;

        case GameMode.Welcome:
            // Preset tutorial
            letters             = new char[] { 'A', 'S', 'E' };
            timeLeft            = 600;
            word                = new Word('A', 'S', 'E');
            word.MatchingWords  = dictData.GetMatchingWords(word);
            lettersText[0].text = word.A.ToString();
            lettersText[1].text = word.B.ToString();
            lettersText[2].text = word.C.ToString();
            break;
        }
    }