Example #1
0
    public List <EndScoreFC> GetHighScoreFC()
    {
        List <EndScoreFC> HighScores = new List <EndScoreFC>();

        int i = 1;

        while (i <= m_LeaderboardLength && PlayerPrefs.HasKey("HighScore" + i + "m_scoreFC"))
        {
            EndScoreFC temp = new EndScoreFC();
            temp.m_scoreFC = PlayerPrefs.GetString("HighScore" + i + "m_scoreFC");
            temp.m_nameFC  = PlayerPrefs.GetString("HighScore" + i + "m_nameFC");
            HighScores.Add(temp);
            i++;
        }

        return(HighScores);
    }
Example #2
0
    public void SaveHighScoreFC(string inputControllerName, float inputScore)
    {
        m_MenuContFC = GetComponent <DLMenuControllerFC>();
        List <EndScoreFC> HighScores = new List <EndScoreFC>();

        int    i         = 1;
        string minutes   = ((int)inputScore / 60).ToString();
        string seconds   = (inputScore % 60).ToString(":00.00");
        string tempScore = minutes + seconds;

        while (i <= m_LeaderboardLength && PlayerPrefs.HasKey("HighScore" + i + "m_scoreFC"))
        {
            EndScoreFC temp = new EndScoreFC();
            temp.m_scoreFC  = PlayerPrefs.GetString("HighScore" + i + "m_scoreFC");
            temp.m_nameFC   = PlayerPrefs.GetString("HighScore" + i + "m_nameFC");
            temp.scoreValue = PlayerPrefs.GetFloat("HighScore" + i + "scoreValue");
            HighScores.Add(temp);
            i++;
        }
        if (HighScores.Count == 0)
        {
            EndScoreFC _temp = new EndScoreFC();
            _temp.m_nameFC   = inputControllerName;
            _temp.m_scoreFC  = tempScore;
            _temp.scoreValue = inputScore;
            m_MenuContFC.AskName(inputControllerName);
            HighScores.Add(_temp);
        }
        else
        {
            for (i = 1; i <= HighScores.Count && i <= m_LeaderboardLength; i++)
            {
                if (inputScore < HighScores[i - 1].scoreValue)
                {
                    EndScoreFC _temp = new EndScoreFC();
                    _temp.m_nameFC   = inputControllerName;
                    _temp.m_scoreFC  = tempScore;
                    _temp.scoreValue = inputScore;
                    m_MenuContFC.AskName(inputControllerName);
                    HighScores.Insert(i - 1, _temp);
                    break;
                }
                if (i == HighScores.Count && i < m_LeaderboardLength)
                {
                    EndScoreFC _temp = new EndScoreFC();
                    _temp.m_nameFC   = inputControllerName;
                    _temp.m_scoreFC  = tempScore;
                    _temp.scoreValue = inputScore;
                    m_MenuContFC.AskName(inputControllerName);
                    HighScores.Add(_temp);
                    break;
                }
            }
        }

        i = 1;
        while (i <= m_LeaderboardLength && i <= HighScores.Count)
        {
            PlayerPrefs.SetString("HighScore" + i + "m_nameFC", HighScores[i - 1].m_nameFC);
            PlayerPrefs.SetString("HighScore" + i + "m_scoreFC", HighScores[i - 1].m_scoreFC);
            PlayerPrefs.SetFloat("HighScore" + i + "scoreValue", HighScores[i - 1].scoreValue);
            i++;
        }
    }