示例#1
0
 public ItemLoot(string item, double probability = 1, int numRequired = 0, double threshold = 0)
 {
     try
     {
         LootDefs.Add(new LootDef(
                          XmlData.Items[XmlData.IdToObjectType[item]],
                          probability,
                          numRequired,
                          threshold));
     }
     catch (Exception e)
     {
         Log.Warn($"Problem adding {item} to mob loot table.");
     }
 }
示例#2
0
        public TierLoot(byte tier, ItemType type, double probability = 1, int numRequired = 0, double threshold = 0)
        {
            int[] types;
            switch (type)
            {
            case ItemType.Weapon:
                types = WeaponT; break;

            case ItemType.Ability:
                types = AbilityT; break;

            case ItemType.Armor:
                types = ArmorT; break;

            case ItemType.Ring:
                types = RingT; break;

            case ItemType.Potion:
                types = PotionT; break;

            default:
                throw new NotSupportedException(type.ToString());
            }

            var items = XmlData.Items
                        .Where(item => Array.IndexOf(types, item.Value.SlotType) != -1)
                        .Where(item => item.Value.Tier == tier)
                        .Select(item => item.Value)
                        .ToArray();

            foreach (var item in items)
            {
                LootDefs.Add(new LootDef(
                                 item,
                                 probability / items.Length,
                                 numRequired,
                                 threshold));
            }
        }