Exemplo n.º 1
0
        /// <summary>
        /// Displays the 5 best scores and saves the scores to a file
        /// </summary>
        public void WriteScore()
        {
            List <UInt64> ScoreList;

            if (File.Exists("score.xml")) //check if file exists before trying to read
            {
                ScoreList = ListIO.ReadList <UInt64>("score.xml");
                ScoreList.Add(Data.Score);
                ScoreList.Sort();
                ScoreList.Reverse();
                if (ScoreList.Count > 5) //remove the excess scores
                {
                    ScoreList.RemoveAt(5);
                }
            }
            else //generate new file if it deos not exists
            {
                ScoreList = new List <UInt64>
                {
                    Data.Score
                };
            }
            byte Line = 3;

            foreach (UInt64 CurrScore in ScoreList) //write scores
            {
                Console.SetCursorPosition(56, Line);
                Console.Write(CurrScore.ToString());
                Line += 1;
            }
            ListIO.WriteList <UInt64>("score.xml", ScoreList);
            ScoreList = null;
        }
Exemplo n.º 2
0
    public static void Exit()
    {
        for (int i = 0; i < roles.roleList.Count; i++)
        {
            Dictionary <int, ReviewRecord> .Enumerator iter1 = roles.roleList[i].reviews.GetEnumerator();
            while (iter1.MoveNext())
            {
                roles.roleList[i].reviewList.Add(iter1.Current.Value);
            }

            Dictionary <string, float> .Enumerator iter2 = roles.roleList[i].scores.GetEnumerator();
            while (iter2.MoveNext())
            {
                CurrScore score = new CurrScore();
                score.curriculums = iter2.Current.Key;
                score.value       = iter2.Current.Value;
                roles.roleList[i].scoreList.Add(score);
            }
        }

        roles.roleList.Sort((Role x, Role y) =>
        {
            if (x.ticks < y.ticks)
            {
                return(-1);
            }
            else if (x.ticks == y.ticks)
            {
                return(0);
            }
            else
            {
                return(1);
            }
        });

        string path = Application.persistentDataPath + "/user.json";
        string json = JsonUtility.ToJson(roles);

        File.WriteAllText(path, json);
    }