Esempio n. 1
0
 public bool LoadRooms()
 {
     MapRoom[] temp = MapRoom.DeserializeFromXML("MapRooms.xml");
     if (temp == null)
     {
         return(false);
     }
     foreach (MapRoom MR in temp)
     {
         if (!this.rooms.ContainsKey(MR.Name))
         {
             this.rooms.Add(MR.Name, MR);
         }
         else
         {
             TextBoxStreamWriter.DefaultLog.WriteLine("World: Repeated room");
         }
     }
     return(true);
 }
Esempio n. 2
0
        public static bool SerializeToXML(MapRoom[] mapRooms, string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(MapRoom[]));
            if (File.Exists(path))
            {
                string[] emptyStrings = { "" };
                File.WriteAllLines(path, emptyStrings);
            }
            else
                File.Create(path);

            try
            {
                Stream stream = File.OpenWrite(path);
                serializer.Serialize(stream, mapRooms);
                stream.Close();
            }
            catch
            {
                return false;
            }
            return true;
        }
Esempio n. 3
0
 public bool SaveRooms()
 {
     return(MapRoom.SerializeToXML(this.rooms.Values.ToArray(), "MapRooms.xml"));
 }