public void Load(XElement shipDesign, GameMain gameMain)
{
Name = shipDesign.Attribute("Name").Value;
DesignID = int.Parse(shipDesign.Attribute("DesignID").Value);
Size = int.Parse(shipDesign.Attribute("Size").Value);
WhichStyle = int.Parse(shipDesign.Attribute("WhichStyle").Value);
Engine = new KeyValuePair<Equipment, float>(LoadEquipment(shipDesign.Attribute("Engine").Value, gameMain), float.Parse(shipDesign.Attribute("NumOfEngines").Value));
Armor = LoadEquipment(shipDesign.Attribute("Armor").Value, gameMain);
Shield = LoadEquipment(shipDesign.Attribute("Shield").Value, gameMain);
Computer = LoadEquipment(shipDesign.Attribute("Computer").Value, gameMain);
ECM = LoadEquipment(shipDesign.Attribute("ECM").Value, gameMain);
int iter = 0;
foreach (var weapon in shipDesign.Elements("Weapon"))
{
if (weapon.Attribute("Name").Value == "null")
{
Weapons[iter] = new KeyValuePair<Equipment, int>();
}
else
{
var weaponTech = LoadEquipment(weapon.Attribute("Name").Value, gameMain);
weaponTech.UseSecondary = bool.Parse(weapon.Attribute("IsSecondary").Value);
Weapons[iter] = new KeyValuePair<Equipment, int>(weaponTech, int.Parse(weapon.Attribute("NumOfMounts").Value));
}
iter++;
}
iter = 0;
foreach (var special in shipDesign.Elements("Special"))
{
if (special.Attribute("Name").Value == "null")
{
Specials[iter] = null;
}
else
{
var specialTech = LoadEquipment(special.Attribute("Name").Value, gameMain);
Specials[iter] = specialTech;
}
iter++;
}
}