예제 #1
0
    public void CarregarScores()
    {
        string folderPath = (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer ? Application.persistentDataPath : Application.dataPath);

        string path = folderPath + "/FasesNovas/scores.txt";

        if (File.Exists(path))
        {
            StreamReader reader = new StreamReader(path);
            do
            {
                string[] dados = reader.ReadLine().Split(',');

                int indice = fasesPadrao.FindIndex(x => x.nomeArquivo == dados[0]);
                if (indice == -1)
                {
                    indice = fasesUsuario.FindIndex(x => x.nomeArquivo == dados[0]);
                    Fase temp = fasesUsuario[indice];
                    temp.score = int.Parse(dados[1]);
                    temp.AtualizarScore();
                    fasesUsuario[indice] = temp;
                }
                else
                {
                    Fase temp = fasesPadrao[indice];
                    temp.score = int.Parse(dados[1]);
                    temp.AtualizarScore();
                    fasesPadrao[indice] = temp;
                }
            } while (!reader.EndOfStream);


            reader.Close();
        }
    }
예제 #2
0
    public void AtualizarTextos(int score, string nomeArquivo)
    {
        int indice = fasesPadrao.FindIndex(x => x.nomeArquivo == nomeArquivo);

        if (indice == -1)
        {
            indice = fasesUsuario.FindIndex(x => x.nomeArquivo == nomeArquivo);
            Fase temp = fasesUsuario[indice];
            temp.score = score;
            temp.AtualizarScore();
            fasesUsuario[indice] = temp;
        }
        else
        {
            Fase temp = fasesPadrao[indice];
            temp.score = score;
            temp.AtualizarScore();
            fasesPadrao[indice] = temp;
        }
        EscreverScores();
    }