public bool TryPickupItem() { if (itemOnGround != null) { ground.RemoveItem(transform.position); Item replacedItem; switch (itemOnGround.Slot) { case InventorySlot.Weapon: replacedItem = ReplaceWeapon((Weapon)itemOnGround); break; case InventorySlot.BodyArmor: replacedItem = ReplaceArmor((BodyArmor)itemOnGround); break; case InventorySlot.Shield: replacedItem = ReplaceShield((Shield)itemOnGround); break; case InventorySlot.Consumable: ((IConsumable)itemOnGround).Use(gameObject); return(true); default: throw new System.ComponentModel.InvalidEnumArgumentException("Internal error: unidentified inventory slot."); } ground.TryPlaceItemOnGround(replacedItem, transform.position); return(true); } else { return(false); } }
public void Invoke() { for (int i = 0; i < numItemsToDrop; i++) { ItemTemplate chosenTemplate = itemClass.FetchItem(); if (chosenTemplate != null) { Item item = itemFactory.Build(chosenTemplate); ground.TryPlaceItemOnGround(item, transform.position); } } }