コード例 #1
0
        public override void ReadNode(XElement node)
        {
            if (String.IsNullOrEmpty(node.Value))
            {
                ItemInstance = null;
            }
            else
            {
                _itemInstance = new MDRItemInstance();

                var item = CoM.Items.ByID(int.Parse(node.Value));

                if (item == null)
                {
                    Trace.LogWarning("Data Error [Store]: Inventory references an item that doesn't exist.  Item ID {0}.  This item will be ignored.", node.Value);
                    _itemInstance = null;
                    return;
                }

                _itemInstance.Item = item;

                Quantity = ReadAttributeInt(node, "Quantity", 1);
                _itemInstance.RemainingCharges = ReadAttributeInt(node, "Charges", 0);
                _itemInstance.IDLevel          = IdentificationLevel.FromName(ReadAttribute(node, "IDLevel", IdentificationLevel.Full.Name));
                _itemInstance.Cursed           = ReadAttributeBool(node, "Cursed");
                _itemInstance.KnownToBeCursed  = ReadAttributeBool(node, "KnownToBeCursed", false);
            }
        }
コード例 #2
0
 /** Updates the identification level */
 private void setIDLevel(IdentificationLevel idLevel)
 {
     _idLevel = idLevel;
     if (idLevel == IdentificationLevel.Full)
     {
         KnownToBeCursed = Item.CurseType != ItemCurseType.None;
     }
 }
コード例 #3
0
        public static MDRItemInstance Create(MDRItem item, IdentificationLevel idLevel = null)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            MDRItemInstance result = new MDRItemInstance();

            result.Item             = item;
            result.IDLevel          = idLevel ?? IdentificationLevel.Full;
            result.RemainingCharges = Math.Min(item.DefaultCharges, item.Usable ? 1 : 0);
            result.Cursed           = (item.CurseType != ItemCurseType.None);
            result.KnownToBeCursed  = (idLevel == IdentificationLevel.Full) && (result.Cursed);
            return(result);
        }