Exemplo n.º 1
0
 public XMLHighScores(XElement SourceNode, Object pPersistenceData)
 {
     Name = SourceNode.GetAttributeString("Name", "Default");
     foreach (var ScoreElement in SourceNode.Elements("Score"))
     {
         XMLScoreEntry <T> newEntry = new XMLScoreEntry <T>(ScoreElement, pPersistenceData);
         ScoreEntries.Add(newEntry.Score, newEntry);
     }
 }
Exemplo n.º 2
0
 private void InitializeRandom(Func <XMLScoreEntry <T>, T> CustomDataFunc)
 {
     for (int i = 0; i < MaximumSize; i++)
     {
         int               NameIndex  = rgen.Next(RandomNames.Length);
         String            sUseName   = RandomNames[NameIndex];
         XMLScoreEntry <T> buildentry = new XMLScoreEntry <T>(sUseName, rgen.Next(MaximumScore), default(T));
         if (CustomDataFunc != null)
         {
             buildentry.CustomData = CustomDataFunc(buildentry);
         }
         ScoreEntries.Add(buildentry.Score, buildentry);
     }
 }
Exemplo n.º 3
0
        public IHighScoreEntry <T> Submit(string pName, int Score, T ScoreData)
        {
            XMLScoreEntry <T> buildentry = new XMLScoreEntry <T>(pName, Score, ScoreData);
            int eligibleresult           = IsEligible(Score);

            if (eligibleresult == -1)
            {
                return(null);
            }


            ScoreEntries.Add(Score, buildentry);

            //until we have MaximumSize items, remove the item with the smallest score.
            while (ScoreEntries.Count > MaximumSize)
            {
                ScoreEntries.RemoveAt(ScoreEntries.Count - 1);
            }

            return(buildentry);
        }