Ejemplo n.º 1
0
 internal Armor(string type, Material material, Quality quality)
 {
     Attributes["Type"] = type;
     m_material = material;
     m_quality = quality;
     Calculate();
 }
Ejemplo n.º 2
0
 public override void ReadXml(XmlReader reader)
 {
     m_material = ItemFactory.Instance.MaterialFactory.GetMaterial(Type, reader.ReadElementContentAsString());
     m_quality = ItemFactory.Instance.QualityFactory.GetQuality(reader.ReadElementContentAsString());
     Calculate();
 }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
 internal StatsBasedRangedWeapon(IWeaponRange weaponRange, Material material, Quality quality) : base(weaponRange, material, quality)
 {
     if (!weaponRange.IsRanged)
         throw new InvalidOperationException("StatsBasedRangedWeapon with no ranged weaponRange?");
 }
Ejemplo n.º 5
0
 internal StatsBasedWeapon(IWeaponRange weaponRange, Material material, Quality quality) : base(weaponRange)
 {
     m_material = material;
     m_quality = quality;
     Calculate();
 }
Ejemplo n.º 6
0
        private void ReadFileCallback(XmlReader reader, object data)
        {
            if (reader.LocalName != "Materials")
                throw new System.InvalidOperationException("Bad material file");

            bool inAttributes = false;
            Material currentMaterial = null;
            string attributeName = null;
            string attributeValue = null;
            string lastItemType = null;
            while (true)
            {
                reader.Read();
                if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "Materials")
                    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)
                            currentMaterial.Attributes[lastItemType].Add(attributeName, attributeValue);
                        attributeName = null;
                        attributeValue = null;
                    }
                }
                else if (reader.LocalName == "Material")
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        int level = int.Parse(reader.GetAttribute("Level"));
                        string name = reader.GetAttribute("Name");
                        currentMaterial = new Material(name, level);

                        string damageBonus = reader.GetAttribute("DamageBonus");
                        if (damageBonus != null)
                            currentMaterial.MaterialAttributes["DamageBonus"] = damageBonus;

                        string extraCTCost = reader.GetAttribute("ExtraCTCost");
                        if (extraCTCost != null)
                            currentMaterial.MaterialAttributes["ExtraCTCost"] = extraCTCost;

                        string staminaBonus = reader.GetAttribute("StaminaBonus");
                        if (staminaBonus != null)
                            currentMaterial.MaterialAttributes["StaminaBonus"] = staminaBonus;

                        m_materialMapping.Add(currentMaterial.MaterialName, currentMaterial);
                    }
                }
                else if (reader.LocalName == "ValidItem" && reader.NodeType == XmlNodeType.Element)
                {
                    string type = reader.GetAttribute("Type");
                    lastItemType = type;

                    string description = reader.GetAttribute("Description");
                    string fullItemName = reader.GetAttribute("FullItemName");

                    currentMaterial.Descriptions.Add(type, description);
                    currentMaterial.FullItemNamed.Add(type, fullItemName);

                    currentMaterial.Attributes[type] = new Dictionary<string, string>();

                    if (m_validMaterialsForType.ContainsKey(type))
                        m_validMaterialsForType[type].Add(currentMaterial);
                    else
                        m_validMaterialsForType[type] = new List<Material>() { currentMaterial };
                }
                if (reader.LocalName == "Attributes")
                {
                    if (reader.NodeType == XmlNodeType.Element)
                        inAttributes = true;
                    else if (reader.NodeType == XmlNodeType.EndElement)
                        inAttributes = false;
                }
            }
        }