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(); }
public override void ReadXml(XmlReader reader) { reader.ReadStartElement(); base.ReadXml(reader); m_equipedWeapon = ReadWeaponFromSave(reader); m_secondaryWeapon = ReadWeaponFromSave(reader); m_currentHealth = reader.ReadElementContentAsInt(); m_baseMaxHealth = reader.ReadElementContentAsInt(); m_currentStamina = reader.ReadElementContentAsInt(); m_baseMaxStamina = reader.ReadElementContentAsInt(); m_baseCurrentMP = reader.ReadElementContentAsInt(); m_baseMaxMP = reader.ReadElementContentAsInt(); SkillPoints = reader.ReadElementContentAsInt(); LastTurnSeenAMonster = reader.ReadElementContentAsInt(); ChestArmor = (IArmor)Item.ReadXmlEntireNode(reader); Headpiece = (IArmor)Item.ReadXmlEntireNode(reader); Gloves = (IArmor)Item.ReadXmlEntireNode(reader); Boots = (IArmor)Item.ReadXmlEntireNode(reader); m_itemList = new List<Item>(); ReadListFromXMLCore readItemDelegate = new ReadListFromXMLCore(delegate { string typeString = reader.ReadElementContentAsString(); Item newItem = ItemFactory.Instance.CreateBaseItem(typeString); newItem.ReadXml(reader); m_itemList.Add(newItem); }); ListSerialization.ReadListFromXML(reader, readItemDelegate); m_skills = new List<Skill>(); ReadListFromXMLCore readSkillDelegate = new ReadListFromXMLCore(delegate { string skillName = reader.ReadElementContentAsString(); m_skills.Add(SkillFactory.Instance.CreateSkill(skillName)); }); ListSerialization.ReadListFromXML(reader, readSkillDelegate); reader.ReadEndElement(); }