X-Git-Url: https://git.r.bdr.sh/rbdr/super-polarity/blobdiff_plain/078dd693a22cc6793cf6f0f64820369cc606edf6..8bdfcb11a2c1023c684093c0f19f3cc65799e0f8:/SuperPolarity/ScoreScreen.cs diff --git a/SuperPolarity/ScoreScreen.cs b/SuperPolarity/ScoreScreen.cs index bf43275..d879db9 100644 --- a/SuperPolarity/ScoreScreen.cs +++ b/SuperPolarity/ScoreScreen.cs @@ -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)); } }