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); } }
public void HandleOnDropItem(ItemInventoryTile tile) { GD.Print("PlayerInventoryUiManager - HandleOnDropItem"); Item droppedItem = tile.GetParentItem(); inventoryController.RemoveItem(droppedItem); tile.QueueFree(); }
private void HandleUseUnEquip(ItemSlot sourceSlot, ItemInventoryTile usedItem) { if (backPackSlotManager.HasEmptySlots()) { sourceSlot.RemoveItemTile(); backPackSlotManager.AddItemTileToBackpack(usedItem); } }
public void AddItemToUi(Item item) { GD.Print("PlayerInventoryUiManager - AddItemToUi"); ItemInventoryTile tile = itemInventoryTilePrefab.Instance <ItemInventoryTile>(); tile.Init(item); backPackSlotManager.AddItemTileToBackpack(tile); }
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); }
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); }
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(); }
/// <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); }
public void RemoveItemTileFromBackpack(ItemInventoryTile itemTile) { GD.Print("BackPackSlotManager - RemoveItemTileFromBackpack"); }