Exemple #1
0
        /// <summary>
        /// Loads the highscore from the provided file or creates an empty highscore if the file doesn't exist. The highscore is afterwards accessible via 'CurrentScore'
        /// </summary>
        /// <param name="url">URL to the file</param>
        public static void InitializeFromFile(string url)
        {
            if (File.Exists(url))
            {
                try
                {
                    CurrentScore      = Tools.FromJSON <Highscore>(File.ReadAllText(url));
                    CurrentScore._url = url;
                }
                catch
                {
                    CurrentScore = new Highscore(url);
                }
            }
            else
            {
                CurrentScore = new Highscore(url);
            }

            // Automatically order descending by score
            CurrentScore.ScoreList = CurrentScore.ScoreList.OrderByDescending(x => x.Score).ToList();
        }