예제 #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);
            }
        }
예제 #2
0
        public void HandleOnDropItem(ItemInventoryTile tile)
        {
            GD.Print("PlayerInventoryUiManager - HandleOnDropItem");
            Item droppedItem = tile.GetParentItem();

            inventoryController.RemoveItem(droppedItem);
            tile.QueueFree();
        }
예제 #3
0
 private void HandleUseUnEquip(ItemSlot sourceSlot, ItemInventoryTile usedItem)
 {
     if (backPackSlotManager.HasEmptySlots())
     {
         sourceSlot.RemoveItemTile();
         backPackSlotManager.AddItemTileToBackpack(usedItem);
     }
 }
예제 #4
0
        public void AddItemToUi(Item item)
        {
            GD.Print("PlayerInventoryUiManager - AddItemToUi");
            ItemInventoryTile tile = itemInventoryTilePrefab.Instance <ItemInventoryTile>();

            tile.Init(item);

            backPackSlotManager.AddItemTileToBackpack(tile);
        }
예제 #5
0
        public bool AddItemTileToBackpack(ItemInventoryTile itemTile)
        {
            GD.Print("BackPackSlotManager - AddItemTileToBackpack");
            BackPackSlot slot = GetEmptySlot();

            // There aren't any open slots :'(
            if (slot == null)
            {
                return(false);
            }

            slot.AddItemTile(itemTile);
            return(true);
        }
예제 #6
0
        public List <EquipmentSlot> FindCompatibleSlot(ItemInventoryTile tile)
        {
            List <EquipmentSlot> compatibleSlots = new List <EquipmentSlot>();

            foreach (EquipmentSlot slot in slots)
            {
                if (slot.CanDropDnDItem(tile))
                {
                    compatibleSlots.Add(slot);
                }
            }

            return(compatibleSlots);
        }
예제 #7
0
        public void HandleOnItemUse(ItemSlot sourceSlot, ItemUseType useType)
        {
            ItemInventoryTile usedItem = sourceSlot.GetItemTile();

            if (useType == ItemUseType.CONSUME)
            {
                // TODO
            }
            else if (useType == ItemUseType.EQUIP)
            {
                HandleUseEquip(sourceSlot, usedItem);
            }
            else if (useType == ItemUseType.UNEQUIP)
            {
                HandleUseUnEquip(sourceSlot, usedItem);
            }
        }
        private void HandleOnDragEnded(DragStopPayload payload)
        {
            if (!IsDragging())
            {
                return;
            }

            ItemSlot          origin      = currentStartPayload.originatingSlot;
            ItemInventoryTile tile        = currentStartPayload.draggedTile;
            ItemSlot          destination = payload?.destinationSlot;

            if (payload != null && destination != origin && canDrop)
            {
                if (destination.IsOccupied())
                {
                    origin.RemoveItemTile();

                    ItemInventoryTile tempTile = destination.GetItemTile();
                    destination.RemoveItemTile();

                    origin.AddItemTile(tempTile);
                    destination.DropDnDItem(tile);
                }
                else
                {
                    origin.RemoveItemTile();
                    destination.DropDnDItem(tile);
                }
            }
            else
            {
                origin.CancelDnD();
            }

            currentStartPayload = null;
            DestroyPreview();
        }
예제 #9
0
 /// <summary>
 /// Forward event, override to do something specific.
 /// </summary>
 /// <param name="tile"></param>
 public virtual void HandleOnDropItemOnGround(ItemInventoryTile tile)
 {
     GD.Print("BackPackSlotManager - HandleOnDropItemOnGround");
     OnDropItemOnGround?.Invoke(tile);
 }
예제 #10
0
 public void RemoveItemTileFromBackpack(ItemInventoryTile itemTile)
 {
     GD.Print("BackPackSlotManager - RemoveItemTileFromBackpack");
 }