Esempio n. 1
0
    public static void AddEntry(string name)
    {
        PlayerInformationEntry Entry = new PlayerInformationEntry {
            Name = name, Score = currentScore
        };
        string   jsonString = PlayerPrefs.GetString("Database");
        DataBase db         = JsonUtility.FromJson <DataBase>(jsonString);

        db.PlayerList.Add(Entry);
        SortList(db.PlayerList);
        db.PlayerList.RemoveRange(3, db.PlayerList.Count - 3);
        string jsonDB = JsonUtility.ToJson(db);

        PlayerPrefs.SetString("Database", jsonDB);
    }
Esempio n. 2
0
 public static void SortList(List <PlayerInformationEntry> playerList)
 {
     for (int i = 0; i < (playerList.Count); i++)
     {
         for (int j = i + 1; j < (playerList.Count); j++)
         {
             if (playerList[j].Score > playerList[i].Score)
             {
                 PlayerInformationEntry tmp = playerList[j];
                 playerList[j] = playerList[i];
                 playerList[i] = tmp;
             }
         }
     }
 }