Exemplo n.º 1
0
        private void HandleUseEquip(ItemSlot sourceSlot, ItemInventoryTile usedItem)
        {
            List <EquipmentSlot> compatibleSlots = equipmentSlotsManager.FindCompatibleSlot(usedItem);

            if (compatibleSlots.Count > 0)
            {
                // Place item in empty space
                foreach (EquipmentSlot equipmentSlot in compatibleSlots)
                {
                    // Found empty slot, sweet, we done
                    if (!equipmentSlot.IsOccupied())
                    {
                        sourceSlot.RemoveItemTile();
                        equipmentSlot.DropDnDItem(usedItem);
                        return;
                    }
                }


                // Swap item
                sourceSlot.RemoveItemTile();

                EquipmentSlot     targetSlot = compatibleSlots[0];
                ItemInventoryTile tempTile   = targetSlot.GetItemTile();
                targetSlot.RemoveItemTile();

                sourceSlot.DropDnDItem(tempTile);
                targetSlot.DropDnDItem(usedItem);
            }
        }