internal Armor(string type, Material material, Quality quality) { Attributes["Type"] = type; m_material = material; m_quality = quality; Calculate(); }
public override void ReadXml(XmlReader reader) { m_material = ItemFactory.Instance.MaterialFactory.GetMaterial(Type, reader.ReadElementContentAsString()); m_quality = ItemFactory.Instance.QualityFactory.GetQuality(reader.ReadElementContentAsString()); Calculate(); }
private void GetWeaponArmorParts(string type, int level, int lowLevel, int highLevel, string materialName, string qualityName, out Material material, out Quality quality) { if (qualityName != null) quality = QualityFactory.GetQuality(qualityName); else quality = QualityFactory.GetQualityNoHigherThan(highLevel); if (quality == null) { material = null; return; } if (materialName != null) { material = MaterialFactory.GetMaterial(type, materialName); } else { int minLevelCapNeeded = (int)Math.Max(lowLevel - quality.LevelAdjustment, 0); int levelCapLeft = (int)Math.Max(highLevel - quality.LevelAdjustment, 0); material = MaterialFactory.GetMaterialInLevelRange(type, minLevelCapNeeded, levelCapLeft); } }
internal StatsBasedRangedWeapon(IWeaponRange weaponRange, Material material, Quality quality) : base(weaponRange, material, quality) { if (!weaponRange.IsRanged) throw new InvalidOperationException("StatsBasedRangedWeapon with no ranged weaponRange?"); }
internal StatsBasedWeapon(IWeaponRange weaponRange, Material material, Quality quality) : base(weaponRange) { m_material = material; m_quality = quality; Calculate(); }
private void ReadFileCallback(XmlReader reader, object data) { if (reader.LocalName != "Qualities") throw new System.InvalidOperationException("Bad quality file"); bool inAttributes = false; Quality currentQuality = null; string attributeName = null; string attributeValue = null; while (true) { reader.Read(); if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "Qualities") break; if (inAttributes) { if (reader.NodeType == XmlNodeType.Element) { attributeName = reader.LocalName; } else if (reader.NodeType == XmlNodeType.Text) { attributeValue = reader.Value; } else if (reader.NodeType == XmlNodeType.EndElement) { if (attributeName != null) currentQuality.Attributes.Add(attributeName, attributeValue); attributeName = null; attributeValue = null; } } else if (reader.LocalName == "Quality") { if (reader.NodeType == XmlNodeType.Element) { int levelAdjustment = int.Parse(reader.GetAttribute("LevelAdjustment")); currentQuality = new Quality(reader.GetAttribute("Name"), reader.GetAttribute("Description"), levelAdjustment); m_qualityMapping.Add(currentQuality); } } if (reader.LocalName == "Attributes") { if (reader.NodeType == XmlNodeType.Element) inAttributes = true; else if (reader.NodeType == XmlNodeType.EndElement) inAttributes = false; } } }