public void pushOK() { if (InputText.text != "") { HighScoreClass buffer = new HighScoreClass(PlayerController.time, InputText.text, PlayerController.kills); HighScoreArrayList.LoadScoresToList(); HighScoreArrayList.list.Add(buffer); HighScoreArrayList.list.Sort(new HighScoreClassComparer()); if (HighScoreArrayList.list.Capacity > 10) { HighScoreArrayList.list.RemoveAt(10); } HighScoreArrayList.UploadFileFromList(); //SceneManager.UnloadSceneAsync("SceneForest_lvl_1"); SceneManager.LoadScene("MainMenu"); } }
public static void LoadScoresToList() { try { StreamReader file = new StreamReader(path); while (!file.EndOfStream) { float time = float.Parse(file.ReadLine()); string name = file.ReadLine(); int kills = int.Parse(file.ReadLine()); HighScoreClass buffer = new HighScoreClass(time, name, kills); list.Add(buffer); } file.Close(); list.Sort(new HighScoreClassComparer()); } catch { } }