Esempio n. 1
0
    void SetLetters()
    {
        while (indexList.Count < amountCreators)
        {
            int num = Random.Range(0, letterArray.Count);

            if (!indexList.Contains(num) && indexList.Count < amountCreators - 2)
            {
                if (num != 0 && num != 4 && num != 8 && num != 14 && num != 20)
                {
                    indexList.Add(num);
                }
            }
            else if (!indexList.Contains(num))
            {
                indexList.Add(num);
            }
        }

        int correctLetter = Random.Range(0, amountCreators - 1);

        if (correctLetter == 0)
        {
            creator1.CreateWord(letterArray[indexList[0]], true);
        }
        else
        {
            creator1.CreateWord(letterArray[indexList[0]], false);
        }

        if (correctLetter == 1)
        {
            creator2.CreateWord(letterArray[indexList[1]], true);
        }
        else
        {
            creator2.CreateWord(letterArray[indexList[1]], false);
        }

        if (correctLetter == 2)
        {
            creator3.CreateWord(letterArray[indexList[2]], true);
        }
        else
        {
            creator3.CreateWord(letterArray[indexList[2]], false);
        }

        if (correctLetter == 3)
        {
            creator4.CreateWord(letterArray[indexList[3]], true);
        }
        else if (mode > 0)
        {
            creator4.CreateWord(letterArray[indexList[3]], false);
        }

        if (correctLetter == 4)
        {
            creator5.CreateWord(letterArray[indexList[4]], true);
        }
        else if (mode == (int)Difficulty.difficulty.hard)
        {
            creator5.CreateWord(letterArray[indexList[4]], false);
        }
        indexList.Clear();
    }
Esempio n. 2
0
    void SetNumbers()
    {
        int firstNumber;
        int secondNumber;

        answer.enabled = false;
        int        range   = 0;
        List <int> numList = new List <int>();

        numList.Add(0);

        // Add number families
        if (PlayerPrefs.GetInt("oneFamily") == 1)
        {
            numList.Add(1);
        }
        if (PlayerPrefs.GetInt("twoFamily") == 1)
        {
            numList.Add(2);
        }
        if (PlayerPrefs.GetInt("threeFamily") == 1)
        {
            numList.Add(3);
        }
        if (PlayerPrefs.GetInt("fourFamily") == 1)
        {
            numList.Add(4);
        }
        if (PlayerPrefs.GetInt("fiveFamily") == 1)
        {
            numList.Add(5);
        }
        if (PlayerPrefs.GetInt("sixFamily") == 1)
        {
            numList.Add(6);
        }
        if (PlayerPrefs.GetInt("sevenFamily") == 1)
        {
            numList.Add(7);
        }
        if (PlayerPrefs.GetInt("eightFamily") == 1)
        {
            numList.Add(8);
        }
        if (PlayerPrefs.GetInt("nineFamily") == 1)
        {
            numList.Add(9);
        }
        if (PlayerPrefs.GetInt("tenFamily") == 1)
        {
            numList.Add(10);
        }
        if (PlayerPrefs.GetInt("elevenFamily") == 1)
        {
            numList.Add(11);
        }
        if (PlayerPrefs.GetInt("twelveFamily") == 1)
        {
            numList.Add(12);
        }

        // Percent chance to re-use a missed question
        int chance = Random.Range(0, 10);

        if (loseCondition.missedNumbers.Count >= 1 && chance <= 5)
        {
            firstNumber  = loseCondition.missedNumbers[0][0, 0];
            secondNumber = loseCondition.missedNumbers[0][0, 1];
            loseCondition.missedNumbers.RemoveAt(0);
        }
        else
        {
            firstNumber  = numList[Random.Range(0, numList.Count)];
            secondNumber = Random.Range(0, 12);
        }
        PlayerPrefs.SetInt("firstNumber", firstNumber);
        PlayerPrefs.SetInt("secondNumber", secondNumber);

        // Do the math
        int answerNum = 0;

        if (type == (int)TypeToggle.symbol.addition)
        {
            operation.sprite = numberArray[145];
            answerNum        = firstNumber + secondNumber;
            range            = 12;
        }
        else if (type == (int)TypeToggle.symbol.multiplication)
        {
            operation.sprite = numberArray[146];
            answerNum        = firstNumber * secondNumber;
            range            = numberArray.Count - 2;
        }

        StartCoroutine(PlayAudio(firstNumber, secondNumber));
        firstNum.sprite  = numberArray[firstNumber];
        secondNum.sprite = numberArray[secondNumber];
        answer.sprite    = numberArray[answerNum];

        while (indexList.Count < amountCreators)
        {
            int num = Random.Range(0, range);

            if (!indexList.Contains(num) && num != answerNum)
            {
                indexList.Add(num);
            }
        }

        int correctNumber = Random.Range(0, amountCreators);

        if (correctNumber == 0)
        {
            creator1.CreateWord(numberArray[answerNum], true);
        }
        else
        {
            creator1.CreateWord(numberArray[indexList[0]], false);
        }

        if (correctNumber == 1)
        {
            creator2.CreateWord(numberArray[answerNum], true);
        }
        else
        {
            creator2.CreateWord(numberArray[indexList[1]], false);
        }

        if (correctNumber == 2)
        {
            creator3.CreateWord(numberArray[answerNum], true);
        }
        else
        {
            creator3.CreateWord(numberArray[indexList[2]], false);
        }

        if (correctNumber == 3)
        {
            creator4.CreateWord(numberArray[answerNum], true);
        }
        else if (mode > 0)
        {
            creator4.CreateWord(numberArray[indexList[3]], false);
        }

        if (correctNumber == 4)
        {
            creator5.CreateWord(numberArray[answerNum], true);
        }
        else if (mode == (int)Difficulty.difficulty.hard)
        {
            creator5.CreateWord(numberArray[indexList[4]], false);
        }
        indexList.Clear();
    }