Exemple #1
0
        /// <summary>
        /// Save the awake bestiary
        /// </summary>
        /// <param name="path"></param>
        /// <param name="bestiary"></param>
        private void SaveBestiaryAwake(String path, BestiaryAwake bestiary)
        {
            IFormatter format = new BinaryFormatter();

            using (Stream str = new FileStream(Path.GetFullPath(Path.Combine("Save/", path)), FileMode.OpenOrCreate, FileAccess.Write))
            {
                format.Serialize(str, bestiary);
            }
        }
Exemple #2
0
 /// <summary>
 /// This method load the BestiaryAwake
 /// </summary>
 /// <param name="path"></param>
 /// <param name="bestiary"></param>
 /// <returns>the bestiary awake</returns>
 public BestiaryAwake LoadBestiaryAwake(String path)
 {
     try
     {
         BinaryFormatter formatter = new BinaryFormatter();
         using (FileStream flux = new FileStream(Path.GetFullPath(Path.Combine("Save/", path)), FileMode.Open, FileAccess.Read))
         {
             BestiaryAwake ba = (BestiaryAwake)formatter.Deserialize(flux);
             foreach (MonsterAwake monster in ba.ListBestiary)
             {
                 monster.ImagePath = Path.GetFullPath(Path.Combine("photos/", monster.Name + ".png"));
             }
             return(ba);
         }
     }
     catch
     {
         return(BestiaryAwake.Instance);
     }
 }