// Writes out the "Game Name Art" and all the buttons. static public void ButtonUpdate(List <Button> buttons) { Console.Clear(); if (curMenu == 2) { Statistics.SaveStats(); Data data = FileWrite.Read(Program.Path + Statistics.StatsPath); foreach (KeyValuePair <string, Stat> stat in data.stats) { Console.WriteLine(stat.Value.Name + ": " + stat.Value.Value + " " + stat.Value.Unit); } } else { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(Program.GameNameArt + "\n"); Console.ResetColor(); } foreach (Button button in buttons) { button.DrawButton(); } }
// Saves the players stats. // Adds them up with already existing ones from the save file. // And then writes it all into the same file. public static void SaveStats() { if (File.Exists(Program.Path + StatsPath) && Stats.Count != FileWrite.Read(Program.Path + StatsPath).stats.Count) { AddStats(); } Stats["Distance"].Add((int)Stats["Up"].Value + (int)Stats["Down"].Value + (int)Stats["Right"].Value + (int)Stats["Left"].Value); Stats["Time"].Add((int)Program.GameTime.ElapsedMilliseconds); Program.GameTime.Restart(); if (File.Exists(Program.Path + StatsPath)) { exStats = FileWrite.Read(Program.Path + StatsPath); Data test = exStats; } else { exStats.stats = Stats; foreach (KeyValuePair <string, Stat> stat in exStats.stats) { exStats.stats[stat.Key].SetValue(0); } } foreach (KeyValuePair <string, Stat> stat in Stats) { Stats[stat.Key].Add((int)exStats.stats[stat.Key].Value); } Data data = new Data(Stats); FileWrite.Write(Program.Path + StatsPath, data); AddStats(); }