void AddPlayerInfo(string _name, int _score)
    {
        // add player to leaderboard
        LocalPlayerInfo stats = new LocalPlayerInfo(_name, _score);

        infoList.Add(stats);

        nameIF.text  = "";
        scoreIF.text = "";

        Sort();
    }
    public void LoadLeaderboard()
    {
        string infos = TrinaxPlayerPrefs.GetString(LB_PREFSTRING, "");

        string[] tempInfos = infos.Split(',');

        for (int i = 0; i < tempInfos.Length - 2; i += 2)
        {
            LocalPlayerInfo loadedInfo = new LocalPlayerInfo(tempInfos[i], int.Parse(tempInfos[i + 1]));

            infoList.Add(loadedInfo);
            UpdateHUD();
        }
    }
    void Sort()
    {
        for (int i = infoList.Count - 1; i > 0; i--)
        {
            if (infoList[i].score > infoList[i - 1].score)
            {
                LocalPlayerInfo temp = infoList[i - 1];

                infoList[i - 1] = infoList[i];
                infoList[i]     = temp;
            }
        }

        UpdatePlayerPrefs();
    }
Пример #4
0
 public LocalPlayerInfo()
 {
     singleton = this;
 }