コード例 #1
0
 public virtual void LootItemOnGround(IItem item)
 {
     if (item.GetType().BaseType == typeof(AttackItem))
     {
         AttackItems.AddAttackItem((AttackItem)item);
     }
     if (item.GetType().BaseType == typeof(DefenceItem))
     {
         DefencesItems.AddDefenceItem((DefenceItem)item);
     }
 }
コード例 #2
0
        public void AddAttackItem(AttackItem item)
        {
            var items = AttackItems.FindAll(x => x.Type == item.Type);

            if (items.Count < 2 && item.Type == AttackEnum.Sword)
            {
                AttackItems.Add(item);
            }
            else if (items.Count == 0 && item.Type == AttackEnum.Bow)
            {
                AttackItems.Add(item);
            }
            else
            {
                throw new ItemAlreadyEquipped("You cannot equip this item: " + item.Type + " as you already have a maximum of these items equipped");
            }
        }