X-Git-Url: https://git.r.bdr.sh/rbdr/super-polarity/blobdiff_plain/4fc09567c557a1110180940cca40fd7144921026..8ae8ea0d77ec654dd693b3912562b07a2b539b0f:/SuperPolarity/ScoreScreen.cs diff --git a/SuperPolarity/ScoreScreen.cs b/SuperPolarity/ScoreScreen.cs index bf43275..63418d8 100644 --- a/SuperPolarity/ScoreScreen.cs +++ b/SuperPolarity/ScoreScreen.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -13,7 +13,7 @@ namespace SuperPolarity { protected SpriteFont Font; protected NameChooserWidget nameChooser; - protected Dictionary Scores; + protected List> Scores; public ScoreScreen(SuperPolarity newGame) : base(newGame) { } @@ -23,7 +23,7 @@ namespace SuperPolarity 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(); + Scores = new List>(); ReadScore(); } @@ -59,7 +59,8 @@ namespace SuperPolarity while ((line = sreader.ReadLine()) != null) { string[] parts = line.Split(','); - Scores.Add(parts[0], int.Parse(parts[1])); + var scoreTuple = new Tuple(parts[0], int.Parse(parts[1])); + Scores.Add (scoreTuple); } } } @@ -92,15 +93,15 @@ namespace SuperPolarity 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 entry in sortedDict) { + foreach (Tuple 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)); } }