Exemplo n.º 1
0
        public void Load(string saveFile)
        {
            string path = GetPathFromSaveFile(saveFile);
            Dictionary <string, int> scoreTable = new Dictionary <string, int>();

            using (FileStream stream = File.Open(path, FileMode.Open))
            {
                while (stream.Position != stream.Length)
                {
                    BinaryFormatter formatter   = new BinaryFormatter();
                    string          playerName  = (string)formatter.Deserialize(stream);
                    int             playerScore = (int)formatter.Deserialize(stream);
                    if (scoreTable.ContainsKey(playerName) && scoreTable[playerName] > playerScore)
                    {
                        continue;
                    }
                    scoreTable[playerName] = playerScore;
                }
            }
            entriesController.CreateEntries(scoreTable);
        }