Example #1
0
 public ScoreRecord setPrev(ScoreRecord prev)
 {
     this.Previous = prev;
     prev.Next = this;
     prev.index = this.index - 1;
     return this.Previous;
 }
Example #2
0
 public ScoreRecord setNext( ScoreRecord next)
 {
     this.Next = next;
     next.Previous = this;
     next.index = this.index + 1;
     return this.Next;
 }
Example #3
0
        public void scoreSubmit(int score,float time, String level)
        {
            SortedDictionary<String, ScoreRecord> hiScoreList;
            FileStream hiScore = new FileStream("hiScoreWindowsData", System.IO.FileMode.OpenOrCreate);

            StreamWriter writer = new StreamWriter(hiScore);
            StreamReader reader = new StreamReader(hiScore);

            //hiScoreList = Newtonsoft.Json.Serialization.
            //safe code/////////////
            hiScoreList = new SortedDictionary<string, ScoreRecord>();
            if(hiScoreList.ContainsKey(level)==false){
                ScoreRecord adding = new ScoreRecord(score, time);
                hiScoreList.Add(level, adding);
            }
            else
            {
                ScoreRecord iterate = hiScoreList[level];
               // while(iterate.getNext()!=null){
                    if (iterate.PlayTime > time)
                    {
                        iterate.replace(score, time);
                        //break;
                    }
                   /* if (iterate.index > 8)
                    {
                        break;
                    }
                    iterate = iterate.getNext();*/
               // }
            }
            //end of safe code//////////////
        }
Example #4
0
 public ScoreRecord(int score, float playTime)
 {
     Score = score;
     PlayTime = playTime;
     index = 0;
     Next = null;
     Previous = null;
 }
Example #5
0
        /// <summary>
        /// Submits the given player score and playtime to be added to the given level's highscore list.
        /// </summary>
        public static void scoreSubmit(String level)
        {
            //if no high score records exist in the file, new information is created.

            //otherwise the file is deserialized into a variable.

                //if records for the level do not exist in the folder, then some are created, with the sent data being the initial value
                if (hiScoreList.ContainsKey(level) == false)
                {
                    ScoreRecord adding = new ScoreRecord(score, time);
                    ScoreRecord[] list = new ScoreRecord[10];//To change the amount of highscores saved, alter the number in the brachets.

                    for (int counter = 1; counter < list.Length; counter++){ list[counter] = null; }

                    list[0] = adding;
                    hiScoreList.Add(level, list);
                }
                //otherwise score is sorted into records by score (currently stores ten values.)
                else
                {
                    ScoreRecord adding = new ScoreRecord(score, time);
                    ScoreRecord[] list = hiScoreList[level];

                    for (int counter = 0; counter < list.Length; counter++)
                    {

                        if (list[counter] == null)
                        {
                            list[counter] = adding;
                            break;
                        }

                        else
                        {

                            if (list[counter].Score < adding.Score)
                            {
                                list = insert(list, adding, counter);
                                break;
                            }
                        }

                    }
                    //updates the list information in the dictionary
                    hiScoreList[level] = list;

                }
        }
Example #6
0
        private static ScoreRecord[] insert(ScoreRecord[] list, ScoreRecord adding, int index)
        {
            ScoreRecord temp;

            for (int counter = index; counter < list.Length; counter++)
            {
                temp = list[counter];
                list[counter] = adding;
                adding = temp;
            }

            return list;
        }