Exemplo n.º 1
0
    public void verificaInput(InputField input)   //Debug.Log("Meu ID é = " + inputAtual.Id);      //Debug.Log("entrada: " + inputs[inputAtual.Id].text); Debug.Log("reposta: " + resp[inputAtual.Id]);
    {
        setId inputAtual = input.GetComponent <setId>();

        //CONVERTER TODA A ENTRADA P MINUSCULO
        if (resp[inputAtual.Id].Equals(inputs[inputAtual.Id].text))
        {
            //Debug.Log("resposta certa");
            //inputs[inputAtual.Id].image.color = new Color32(69, 202, 35, 255); //cor verde
            acertos[inputAtual.Id] = 1;
        }
        else
        {
            //Debug.Log("resposta errada");
            //inputs[inputAtual.Id].image.color = new Color32(202, 41, 49, 255);//cor vermelha
            acertos[inputAtual.Id] = 0;
        }
        verficaAcertos();
    }
Exemplo n.º 2
0
 public void setaTabela()
 {
     System.IO.StreamReader file = new System.IO.StreamReader(pathTable);
     for (int i = 0; i < colunas.Length; i++)
     {
         colunas[i].text = "";
     }
     while ((line = file.ReadLine()) != null)
     {
         if (endGame)
         {
             endGame.SetActive(false);
         }
         // Debug.Log("oque?" + line);
         if (line == "NOVA TABELA VERDADE")    //verifica se é um tabela
         {
             line        = file.ReadLine();
             tableNumber = convert(line[0]); // pega o numero dessa tabela e convert p int
             if (tableNumber == counter)     //instruçoes de leitura aqui
             // Debug.Log("Tabela " + tableNumber);
             {
                 line           = file.ReadLine();   //pega expressao
                 expressao.text = line;
                 expr           = splitString(line); //separa expr pra associar uma coluna da tabela a uma variavel
                 line           = file.ReadLine();   //pega num de linhas da tabela
                 numLinhas      = convert(line[0]);  //Debug.Log(numLinhas); Debug.Log(expr);
                 double TotalDeLinhas = Math.Pow(2, Convert.ToDouble(numLinhas));
                 acertos = new int[Convert.ToInt32(TotalDeLinhas)];
                 // Debug.Log("Linhas da tabela");
                 for (int i = 0; i < TotalDeLinhas; i++)                                                               //a partir da conta do total de linhas pega tdas as linhas
                 {
                     line      = file.ReadLine();                                                                      //linha da tabela
                     inputs[i] = Instantiate(inputPrefab, new Vector3(0, 191.1f - (46f * i), 0), Quaternion.identity); //seta novo input em sua coordenada
                     inputs[i].transform.SetParent(ResultadoTransform, false);                                         //seta como child de Resultados
                     setId inputScript = inputs[i].GetComponent <setId>();                                             //busca script pra setar o id de cada input
                     inputScript.Id           = i;
                     inputs[i].characterLimit = 1;                                                                     //seta limite de caracteres como apenas 1
                     if (vars > numLinhas)
                     {
                         expr2 = knowWhatIterate(expr, i);
                         foreach (var item in expr2)
                         {
                             if (item.Contains("-"))
                             {
                                 colunas[(convertColunas[item].GetHashCode() - 5)].text += line[count] + "\n"; //escreve a linha da tabela no postivo
                                 if (line[count] == 'V')                                                       // nega a linha da tabela e escreve no negativo
                                 {
                                     colunas[convertColunas[item].GetHashCode()].text += 'F' + "\n";
                                 }
                                 else
                                 {
                                     colunas[convertColunas[item].GetHashCode()].text += 'V' + "\n";
                                 }
                                 count += 2;
                             }
                             else
                             {
                                 colunas[convertColunas[item].GetHashCode()].text += line[count] + "\n";
                                 count += 2;
                             }
                         }
                         count = 0;
                     }
                     else
                     {
                         foreach (var item in expr)   //associa cada coluna da tabela a uma variavel e printa na tela
                         {
                             if (item != null)
                             {
                                 if (item.Contains("-"))
                                 {
                                     colunas[(convertColunas[item].GetHashCode() - 5)].text += line[count] + "\n"; //escreve a linha da tabela no postivo
                                     if (line[count] == 'V')                                                       // nega a linha da tabela e escreve no negativo
                                     {
                                         colunas[convertColunas[item].GetHashCode()].text += 'F' + "\n";
                                     }
                                     else
                                     {
                                         colunas[convertColunas[item].GetHashCode()].text += 'V' + "\n";
                                     }
                                     count += 2;
                                 }
                                 else
                                 {
                                     colunas[convertColunas[item].GetHashCode()].text += line[count] + "\n";
                                     count += 2;
                                 }
                             }
                         }
                         count = 0;
                     }
                 }
                 file.ReadLine();            //lê o espaço entre a tabela e as respostas
                 resps = file.ReadLine();
                 resp  = splitString(resps); //separa o vetor de respostas p associar aos inputs
                 counter++;
                 break;
             }
         }
         if ((line = file.ReadLine()) == null)   //vai para algum lugar, fim do arquivo de tabelas**
         {
             timeScript timer = time.GetComponent <timeScript>();
             tempos[userCount] = timer.endGame();// Debug.Log("atualiza text");
             for (int i = 0; i < tempos.Length; i++)
             {
                 if (users[i] != null)   //Debug.Log("USERS " + users[i] + "TEMPOS " + tempos[i]);
                 {
                     userTable.text += String.Format("{0,-12}{1,24}\n", users[i], tempos[i] + " segundos");
                 }
             }
             endFile.SetActive(true); //Debug.Log("não tem mais tabela");
             file.DiscardBufferedData();
             line      = file.ReadLine();
             path      = "";
             pathTable = "/Assets/NewAdds/";
             // file.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
         }
     }
 }