/// <summary>
        /// Return if the object being picked up exceeds remaining inventory.
        /// </summary>
        /// <param name="inventoryable"></param>
        /// <returns></returns>
        public override bool TestCapacity(IInventoryable <Vector3Int> inventoryable)
        {
            var size   = inventoryable.Size;
            int volume = size.x * size.y * size.z;

            return(volume <= Remaining);
        }
Exemple #2
0
        //Remove things from the inventory (when sold or potion consumed)
        public string RemoveFromInventory(IInventoryable item)
        {
            Item   it;
            Weapon we;
            Potion po;


            switch (item.TheOriginalType())
            {
            case "Weapon":
                we = (Weapon)item;
                RemoveThisItem(item);
                break;

            case "Item":
                it = (Item)item;
                RemoveThisItem(item);
                break;

            case "Potion":
                po = (Potion)item;
                RemoveThisItem(item);
                break;

            default:
                break;
            }
            return("");
        }
Exemple #3
0
 private void Start()
 {
     _actor         = GetComponent <Actor>();
     _inventoryable = _actor.GetModule <IInventoryable <IItem> >();
     foreach (var item in InitialItems)
     {
         _inventoryable.Inventory.Add(item);
     }
 }
Exemple #4
0
 //adds something to the inventory of type interface IInventoryable
 //Only adds if the backpack is not full
 public string AddToInventory(IInventoryable item)
 {
     if (equipment.Count < inventoryMaxLimit)
     {
         equipment.Add(item);
         return($"{item.Name} has been added to your backpack.");
     }
     else
     {
         return($"Your backpack is full. Limit: {inventoryMaxLimit}/{inventoryMaxLimit}");
     }
 }
Exemple #5
0
        //This method is for removing an item from the equipped list.
        private void RemoveThisItem(IInventoryable item)
        {
            bool removed = false;

            foreach (var inventoryItem in equipment.Where(x => x.Name == item.Name && x.TheChange == item.TheChange))
            {
                if (!removed)
                {
                    equipment.Remove(item);
                    break;
                }
            }
        }
Exemple #6
0
        public virtual Consumption TryTrigger(IContactReactor reactor, ContactEvent contactEvent, int compatibleMounts)
        {
            //Debug.Log("TryTrigger Basic Inv. compat with: " + compatibleMounts + " defMountId: " + defaultMounting.id + " defMask: " + defaultMountingMask);

            IInventoryable <T> iven = reactor as IInventoryable <T>;

            if (ReferenceEquals(iven, null))
            {
                return(Consumption.None);
            }

            if (contactGroups != 0)
            {
                IContactGroupsAssign groups = contactEvent.contactTrigger.ContactGroupsAssign;
                int triggermask             = ReferenceEquals(groups, null) ? 0 : groups.Mask;
                if ((contactGroups.Mask & triggermask) == 0)
                {
                    //Debug.Log("Try trigger... ContactGroup mismatch " + contactGroups.Mask + "<>" + triggermask);
                    return(Consumption.None);
                }
            }

            /// Return if the object being picked up exceeds remaining inventory.
            if (TestCapacity(reactor as IInventoryable <T>) == false)
            {
                //Debug.Log(name + " failed");
                return(Consumption.None);
            }

            /// If both are set to 0 (Root) then consider that a match, otherwise zero for one but not the other is a mismatch (for now)
            if ((compatibleMounts == defaultMountingMask) || (compatibleMounts & defaultMountingMask) != 0)
            {
                // TODO: partial consumption handling needed

                //Debug.Log(name + " <> " + (trigger as Component).name + " <b>success</b>: " + compatibleMounts + " <> " + defaultMountingMask);
                return(Consumption.All);
            }
            else
            {
                //Debug.Log(name + " <> " + (trigger as Component).name + " failed: " + compatibleMounts + " <> " + defaultMountingMask);
                return(Consumption.None);
            }
        }
Exemple #7
0
 public string RemoveFromBackpack(IInventoryable item)
 {
     return(inventory.RemoveFromInventory(item));
 }
Exemple #8
0
 public string AddToInventory(IInventoryable item)
 {
     return(inventory.AddToInventory(item));
 }
Exemple #9
0
 /// <summary>
 /// Return if the object being picked up exceeds remaining inventory. Default implementation always just returns true. Override to create real tests.
 /// </summary>
 /// <param name="inventoryable"></param>
 /// <returns></returns>
 public virtual bool TestCapacity(IInventoryable <T> inventoryable)
 {
     return(true);
 }
Exemple #10
0
 //Add item to backpack
 public string AddToBackpack(IInventoryable item)
 {
     return(backpack.AddToInventory(item));
 }