Пример #1
0
 public static void LoadCharacter(string fileName)
 {
     using (FileStream fs = new FileStream(fileName, FileMode.Open))
     {
         DataContractJsonSerializer jsonFormatter = new DataContractJsonSerializer(typeof(JsonHero));
         JsonHero jsonHero = (JsonHero)jsonFormatter.ReadObject(fs);
         jsonHero.SetValuesInPlayer();
     }
 }
Пример #2
0
        public static void SaveCharacter()
        {
            JsonHero jsonHero = new JsonHero();
            DataContractJsonSerializer jsonFormatter = new DataContractJsonSerializer(typeof(JsonHero));

            using (FileStream fs = new FileStream(Game.player.name + ".json", FileMode.Create))
            {
                jsonFormatter.WriteObject(fs, jsonHero);
            }
        }