예제 #1
0
    public List <EndScoreNMC> GetHighScoreNMC()
    {
        List <EndScoreNMC> HighScores = new List <EndScoreNMC>();

        int i = 1;

        while (i <= m_LeaderboardLength && PlayerPrefs.HasKey("HighScore" + i + "m_scoreNMC"))
        {
            EndScoreNMC temp = new EndScoreNMC();
            temp.m_scoreNMC = PlayerPrefs.GetString("HighScore" + i + "m_scoreNMC");
            temp.m_nameNMC  = PlayerPrefs.GetString("HighScore" + i + "m_nameNMC");
            HighScores.Add(temp);
            i++;
        }

        return(HighScores);
    }
예제 #2
0
//NMC highscore area

    public void SaveHighScoreNMC(string inputControllerName, float inputScore)
    {
        m_MenuContNMC = GetComponent <DLMenuControllerNMC>();
        List <EndScoreNMC> HighScores = new List <EndScoreNMC>();

        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_scoreNMC"))
        {
            EndScoreNMC temp = new EndScoreNMC();
            temp.m_scoreNMC = PlayerPrefs.GetString("HighScore" + i + "m_scoreNMC");
            temp.m_nameNMC  = PlayerPrefs.GetString("HighScore" + i + "m_nameNMC");
            temp.scoreValue = PlayerPrefs.GetFloat("HighScore" + i + "scoreValue");
            HighScores.Add(temp);
            i++;
        }
        if (HighScores.Count == 0)
        {
            EndScoreNMC _temp = new EndScoreNMC();
            _temp.m_nameNMC  = inputControllerName;
            _temp.m_scoreNMC = tempScore;
            _temp.scoreValue = inputScore;
            m_MenuContNMC.AskName(inputControllerName);
            HighScores.Add(_temp);
        }
        else
        {
            for (i = 1; i <= HighScores.Count && i <= m_LeaderboardLength; i++)
            {
                if (inputScore < HighScores[i - 1].scoreValue)
                {
                    EndScoreNMC _temp = new EndScoreNMC();
                    _temp.m_nameNMC  = inputControllerName;
                    _temp.m_scoreNMC = tempScore;
                    _temp.scoreValue = inputScore;
                    m_MenuContNMC.AskName(inputControllerName);
                    HighScores.Insert(i - 1, _temp);
                    break;
                }
                if (i == HighScores.Count && i < m_LeaderboardLength)
                {
                    EndScoreNMC _temp = new EndScoreNMC();
                    _temp.m_nameNMC  = inputControllerName;
                    _temp.m_scoreNMC = tempScore;
                    _temp.scoreValue = inputScore;
                    m_MenuContNMC.AskName(inputControllerName);
                    HighScores.Add(_temp);
                    break;
                }
            }
        }

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