示例#1
0
 public virtual void RequestAddAt(InventoryItemView item, InventorySlot slot)
 {
     desiredPositions.Clear();//Clear the desired positions to remove any data of items that were failed to be added
     if (slot != null && item != null && ContainsSlot(slot))
     {
         if (!slot.ContainsItem())//Slot is empty - standard add
         {
             if (_inventoryModel is ArrayInventory)
             {
                 desiredPositions.Add(item.InventoryItem, GetSlotPosition(slot));
                 (_inventoryModel as ArrayInventory).AddItemAt(item.InventoryItem, GetSlotPosition(slot)[0]);//Pass the column number i.e slot position [0]
             }
             else
             {
                 desiredPositions.Add(item.InventoryItem, GetSlotPosition(slot));
                 _inventoryModel.AddItem(item.InventoryItem);
             }
         }
         else
         {
             if (slot.InventoryItem.IsStackable)//Attempt to stack item
             {
             }
             else//Not stackable - attempt to swap items
             {
             }
         }
     }
 }
示例#2
0
        public InventoryItemView RemoveInventoryItem()
        {
            InventoryItemView result = _inventoryItem;

            _inventoryItem = null;

            return(result);
        }
示例#3
0
        public bool AddInventoryItem(InventoryItemView item)
        {
            bool result = false;

            if (_inventoryItem == null)
            {
                _inventoryItem = item;
                result         = true;
            }

            //NOTE: Need to handle communication with the underlying inventory Model
            //i.e. add the item to the Model (may be handled at higher level...)
            return(result);
        }
        public override void RequestAddAt(InventoryItemView item, InventorySlot slot)
        {
            desiredPositions.Clear();//Clear the desired positions to remove any data of items that were failed to be added
            if (slot != null && item != null && ContainsSlot(slot))
            {
                if (!slot.ContainsItem())//Slot is empty - standard add
                {
                    //inventoryModel should always be an EquippedToolInventory
                    if (_inventoryModel is EquippedToolInventory && (_inventoryModel as EquippedToolInventory).Owner != null)
                    {
                        //Route control of adding tools to the EquippedItemsInventory that owns the EquippedToolInventory
                        if (item.InventoryItem is ToolInventoryItem)
                        {
                            (_inventoryModel as EquippedToolInventory).Owner.AddToolAt((item.InventoryItem as ToolInventoryItem), (_inventoryModel as EquippedToolInventory));
                        }
                    }

                    /* if (_inventoryModel is ArrayInventory)
                     * {
                     *   desiredPositions.Add(item.InventoryItem, GetSlotPosition(slot));
                     *   (_inventoryModel as ArrayInventory).AddItemAt(item.InventoryItem, GetSlotPosition(slot)[0]);//Pass the column number i.e slot position [0]
                     * }
                     * else
                     * {
                     *
                     *   desiredPositions.Add(item.InventoryItem, GetSlotPosition(slot));
                     *   _inventoryModel.AddItem(item.InventoryItem);
                     * }*/
                }
                else
                {
                    if (slot.InventoryItem.IsStackable)//Attempt to stack item
                    {
                    }
                    else//Not stackable - attempt to swap items
                    {
                    }
                }
            }
        }
示例#5
0
 public virtual void OnRequestSwapItems(InventoryItemView localItem, InventoryItemView itemToSwap)
 {
 }
示例#6
0
 public InventorySlot(Vector2 positionRelative, Vector2 parentPosition, InventoryItem item, InventoryView owner)
     : this(positionRelative, parentPosition, owner)
 {
     _inventoryItem = new InventoryItemView(item, Vector2.Zero, _positionAbsolute, this);
 }