-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
{
protected SpriteFont Font;
protected NameChooserWidget nameChooser;
- protected Dictionary<string, int> Scores;
+ protected List<Tuple<String, int>> Scores;
public ScoreScreen(SuperPolarity newGame) : base(newGame) { }
nameChooser = new NameChooserWidget(Game, new Vector2(40, Game.GraphicsDevice.Viewport.Height / 4));
InputController.RegisterEventForButton("OK", Buttons.A);
InputController.RegisterEventForKey("OK", Keys.Z);
- Scores = new Dictionary<string, int>();
+ Scores = new List<Tuple<String, int>>();
ReadScore();
}
while ((line = sreader.ReadLine()) != null)
{
string[] parts = line.Split(',');
- Scores.Add(parts[0], int.Parse(parts[1]));
+ var scoreTuple = new Tuple<String, int>(parts[0], int.Parse(parts[1]));
+ Scores.Add (scoreTuple);
}
}
}
protected void DrawScores(SpriteBatch spriteBatch)
{
- var sortedDict = (from entry in Scores orderby entry.Value descending select entry)
- .Take(5)
- .ToDictionary(pair => pair.Key, pair => pair.Value);
+ var sortedList = (from entry in Scores orderby entry.Item2 descending select entry)
+ .Take (5)
+ .ToList ();
var i = 0;
- foreach (KeyValuePair<string, int> entry in sortedDict) {
+ foreach (Tuple<string, int> entry in sortedList) {
i++;
- spriteBatch.DrawString(Font, entry.Key + " " + entry.Value, new Vector2(40, Game.GraphicsDevice.Viewport.Height / 2 + 100 + (32 * i)), new Color(0, 0, 0, 64));
+ spriteBatch.DrawString(Font, entry.Item1 + " " + entry.Item2, new Vector2(40, Game.GraphicsDevice.Viewport.Height / 2 + 100 + (32 * i)), new Color(0, 0, 0, 64));
}
}