Exemple #1
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     m_stairMapping = new Dictionary<Guid, Point>();
     reader.ReadStartElement();
     int count = reader.ReadElementContentAsInt();
     for (int i = 0; i < count; ++i)
     {
         Guid g = new Guid(reader.ReadElementContentAsString());
         Point destination = new Point();
         destination = destination.ReadXml(reader);
         m_stairMapping[g] = destination;
     }
     reader.ReadEndElement();
 }
Exemple #2
0
        public void ReadXml(XmlReader reader)
        {
            reader.ReadStartElement();

            m_width = reader.ReadElementContentAsInt();
            m_height = reader.ReadElementContentAsInt();
            m_map = new MapTile[m_width, m_height];

            for (int i = 0; i < m_width; ++i)
            {
                for (int j = 0; j < m_height; ++j)
                {
                    m_map[i, j] = new MapTile();
                    m_map[i, j].ReadXml(reader);
                }
            }

            // Read Map Features
            m_mapObjects = new List<IMapObjectCore>();

            ReadListFromXMLCore readDelegate = new ReadListFromXMLCore(delegate
            {
                string typeString = reader.ReadElementContentAsString();
                MapObject newObj = MapObjectFactory.Instance.CreateMapObject(typeString);
                newObj.ReadXml(reader);
                m_mapObjects.Add(newObj);
            });
            ListSerialization.ReadListFromXML(reader, readDelegate);

            // Read Monsters
            m_monsterList = new List<Monster>();

            readDelegate = new ReadListFromXMLCore(delegate
            {
                string typeString = reader.ReadElementContentAsString();
                int baseLevel = reader.ReadElementContentAsInt();
                Monster newObj = MonsterFactory.Instance.CreateMonster(typeString, baseLevel);
                newObj.ReadXml(reader);
                m_monsterList.Add(newObj);
            });
            ListSerialization.ReadListFromXML(reader, readDelegate);

            // Read Items
            m_items = new List<Pair<Item, Point>>();

            readDelegate = new ReadListFromXMLCore(delegate
            {
                string typeString = reader.ReadElementContentAsString();
                Item newItem = ItemFactory.Instance.CreateBaseItem(typeString);
                newItem.ReadXml(reader);
                Point position = new Point();
                position = position.ReadXml(reader);
                m_items.Add(new Pair<Item, Point>(newItem, position));
            });
            ListSerialization.ReadListFromXML(reader, readDelegate);

            reader.ReadEndElement();
        }