private void readBuilding(XmlReader inReader) { Building building = new Building(); while (inReader.Read()) { if (inReader.NodeType == XmlNodeType.Element) { switch (inReader.Name.ToLower()) { case "name": building.Name = inReader.ReadElementString(); break; case "identifier": building.Identifier = inReader.ReadElementString(); break; case "type": switch (inReader.ReadElementString().ToLower()) { case "pollutionreducer": building.Type = BuildingTypes.PollutionReducer; break; case "powerplant": building.Type = BuildingTypes.Powerplant; break; case "house": building.Type = BuildingTypes.House; break; case "storage": building.Type = BuildingTypes.Storage; break; } break; case "properties": readProperties(inReader.ReadSubtree(), building.Values); break; case "active": readActive(inReader.ReadSubtree(), building.Values); break; case "passive": readPassive(inReader.ReadSubtree(), building.Values); break; case "construct": readConstruct(inReader.ReadSubtree(), building.Values); break; case "upgrades": readUpgrades(inReader.ReadSubtree(), building); break; } } } if (building.isValid()) Buildings.Add(building); }
private void readUpgrades(XmlReader inReader, Building inBuilding) { while (inReader.Read()) { if (inReader.NodeType == XmlNodeType.Element && inReader.Name.ToLower() == "upgrade") { readUpgrade(inReader.ReadSubtree(), inBuilding); } } }
private void readUpgrade(XmlReader inReader, Building inBuilding) { Upgrade upgrade = new Upgrade(); while (inReader.Read()) { if (inReader.NodeType == XmlNodeType.Element) { switch (inReader.Name.ToLower()) { case "name": upgrade.Name = inReader.ReadElementString(); break; case "properties": readProperties(inReader.ReadSubtree(), upgrade.Values); break; case "active": readActive(inReader.ReadSubtree(), upgrade.Values); break; case "passive": readPassive(inReader.ReadSubtree(), upgrade.Values); break; case "construct": readConstruct(inReader.ReadSubtree(), upgrade.Values); break; } } } inBuilding.Upgrades.Add(upgrade); }