Пример #1
0
    /// <summary>
    /// Comprueba si hay un récord en las puntuaciones
    /// </summary>
    /// <param name="i"></param>
    /// <param name="timeInSec"></param>
    /// <param name="deaths"></param>
    static void LookForVariables(int i, int timeInSec, int deaths)
    {
        int j, savedTime, savedDeaths;

        for (j = i + 2; data[j] != '-'; j++)
        {
            ;
        }
        Int32.TryParse(data.Substring(j + 1, 4), out savedTime);
        Int32.TryParse(data.Substring(j + 5, 3), out savedDeaths);
        string dataRecord;

        if (timeInSec < savedTime)
        {
            dataRecord = AddZeroes(timeInSec.ToString(), true);
            data       = data.Substring(0, j + 1) + dataRecord + data.Substring(j + 5);

            bestTime.text = TimeCounter.ConvertSecsToString(timeInSec);
            UpdateCloudData();
        }

        else
        {
            bestTime.text = TimeCounter.ConvertSecsToString(savedTime);
        }

        if (deaths < savedDeaths)
        {
            dataRecord = AddZeroes(deaths.ToString(), false);
            if (j + 8 < data.Length)
            {
                data = data.Substring(0, j + 5) + dataRecord + data.Substring(j + 8);
            }
            else
            {
                data = data.Substring(0, j + 5) + dataRecord;
            }

            bestDeaths.text = deaths.ToString();
            UpdateCloudData();
        }

        else
        {
            bestDeaths.text = savedDeaths.ToString();
        }
    }
Пример #2
0
    /// <summary>
    /// Actualizo los datos mediante los números pasados
    /// </summary>
    /// <param name="timeInSec"></param>
    /// <param name="deaths"></param>
    public static void UpdateCurrentNumbers(int timeInSec, int deaths)
    {
        InitializateVariables();
        title.text         = "Level " + SceneManager.GetActiveScene().name + " completed";
        currentTime.text   = TimeCounter.ConvertSecsToString(timeInSec);
        currentDeaths.text = deaths.ToString();

        Int32.TryParse(SceneManager.GetActiveScene().name, out currentLvl);
        if (IsNewLevel())
        {
            bestTime.text   = currentTime.text;
            bestDeaths.text = currentDeaths.text;
            SaveNewData(timeInSec, deaths);
        }

        else
        {
            CheckData(timeInSec, deaths);
        }
    }