/// <summary>
        /// This adds the item directly to the player's inventory without adding it to the UI.  It assumes the player
        /// dragged the Item into their inventory.
        /// </summary>
        private void HandleOnChestItemTaken(ItemInventoryTile tile)
        {
            Item item = tile.GetParentItem();

            currentChest.RemoveItem(item);
            inventoryController.AddItem(item, false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Just process and forward the event.  Equipment tiles should override this to handle unequipping
        /// </summary>
        public virtual void DropItem()
        {
            GD.Print("ItemSlot - DropItem");
            ItemInventoryTile tempTile = currentTile;

            RemoveItemTile();
            OnDropItemOnGround?.Invoke(tempTile);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add an item to a tile.  This should be used as a hook for equipment to equip
        /// </summary>
        public virtual void AddItemTile(ItemInventoryTile tile)
        {
            GD.Print("ItemSlot - AddItemTile");
            tile.SetSlot(this);
            currentTile = tile;

            AddChild(tile);
        }
Ejemplo n.º 4
0
        public void HideMenu()
        {
            Visible = false;

            currentSlot = null;
            currentTile = null;
            currentItem = null;
        }
        public void LoadChest(LootChest chest)
        {
            currentChest = chest;

            foreach (Item item in chest.GetContainedItems())
            {
                ItemInventoryTile tile = itemInventoryTilePrefab.Instance <ItemInventoryTile>();
                tile.Init(item);
                AddTileToSlot(tile);
            }
        }
Ejemplo n.º 6
0
        public override bool CanDropDnDItem(ItemInventoryTile tile)
        {
            GD.Print("ArmorSlot - CanDropDnDItem");
            Item item = tile.GetParentItem();

            // Cast to Armor and get stats
            if (item is IEquipable && item is Armor a)
            {
                ArmorStats stats = a.GetStats();
                // Verify matching slot types
                if (stats.slotType == armorSlotType)
                {
                    // Return true even if we are occupied so we can swap the items
                    return(true);
                }
            }

            // Failed the conversion tree, so the item is not the right type for this slot
            return(false);
        }
        /// <summary>
        /// Unload the ItemInventoryTiles in the LootChestMenu, this should NOT remove the item from the original chest
        /// </summary>
        public void UnloadChest()
        {
            // Dispose of chest tiles
            for (int row = 0; row < 4; row++)
            {
                for (int col = 0; col < 2; col++)
                {
                    LootChestSlot slot = chestInventorySlots[row, col];
                    if (slot.IsOccupied())
                    {
                        ItemInventoryTile tile = slot.GetItemTile();
                        slot.RemoveItemTileNoPropagate();   // Do not remove the Item from the Chest!!
                        tile.QueueFree();
                    }
                }
            }

            currentChest.Close();
            currentChest = null;
        }
        private void HandleOnLootAllPressed()
        {
            for (int row = 0; row < 4; row++)
            {
                for (int col = 0; col < 2; col++)
                {
                    LootChestSlot slot = chestInventorySlots[row, col];
                    if (slot.IsOccupied() && backPackSlotManager.HasEmptySlots())
                    {
                        // Take ItemTile from Chest
                        ItemInventoryTile tile = slot.GetItemTile();
                        slot.RemoveItemTile();

                        // Add to the Backpack and to the inventory
                        backPackSlotManager.AddItemTileToBackpack(tile);
                        inventoryController.AddItem(tile.GetParentItem(), false);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public override bool CanDropDnDItem(ItemInventoryTile tile)
        {
            GD.Print("TrinketSlot - CanDropDnDItem");
            Item item = tile.GetParentItem();

            // Cast to Armor and get stats
            if (item is IEquipable && item is Trinket t)
            {
                TrinketStats stats = t.GetStats();
                // Verify matching slot types
                if (stats.equipType == TrinketEquipType.RING &&
                    (trinketSlotType == TrinketSlotType.LEFT_RING || trinketSlotType == TrinketSlotType.RIGHT_RING))
                {
                    // Return true even if we are occupied so we can swap the items
                    return(true);
                }
            }

            // Failed the conversion tree, so the item is not the right type for this slot
            return(false);
        }
Ejemplo n.º 10
0
        public void ShowMenu(ItemSlot itemSlot)
        {
            currentSlot = itemSlot;
            currentTile = itemSlot.GetItemTile();
            if (currentTile == null)
            {
                HideMenu();
                return;
            }

            currentItem = currentTile.GetParentItem();
            if (currentItem == null)
            {
                HideMenu();
                GD.PrintErr("Null Item?");
                return;
            }

            SelectButtons();
            PositionContainer();

            Visible = true;
        }
Ejemplo n.º 11
0
        public override bool CanDropDnDItem(ItemInventoryTile tile)
        {
            GD.Print("WeaponSlot - CanDropDnDItem");
            Item item = tile.GetParentItem();

            // Cast to Armor and get stats
            if (item is IEquipable && item is Weapon w)
            {
                WeaponStats stats = w.GetStats();
                // Verify matching slot types
                if (weaponSlotTypeType == WeaponSlotType.MAIN_HAND)
                {
                    return(stats.weaponEquipType != WeaponEquipType.OFF_HAND);
                }
                else if (weaponSlotTypeType == WeaponSlotType.OFF_HAND)
                {
                    return(stats.weaponEquipType != WeaponEquipType.MAIN_HAND);
                }
            }

            // Failed the conversion tree, so the item is not the right type for this slot
            return(false);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Remove an item from a tile.  This should be used as a hook for equipment to unequip
 /// </summary>
 public virtual void RemoveItemTile()
 {
     GD.Print("ItemSlot - RemoveItemTile");
     RemoveChild(currentTile);
     currentTile = null;
 }
Ejemplo n.º 13
0
 public override bool CanDropDnDItem(ItemInventoryTile tile)
 {
     GD.Print("LootChestSlot - CanDropDnDItem");
     return(false);
 }
        private void AddTileToSlot(ItemInventoryTile tile)
        {
            LootChestSlot slot = GetEmptySlot();

            slot.AddItemTile(tile);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Drop the item tile onto this Slot
 /// </summary>
 public virtual void DropDnDItem(ItemInventoryTile tile)
 {
     GD.Print("ItemSlot - DropDnDItem");
     AddItemTile(tile);
     tile.Visible = true;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Can this Tile accept the drag and drop item?
 /// </summary>
 public virtual bool CanDropDnDItem(ItemInventoryTile tile)
 {
     GD.Print("ItemSlot - CanDropDnDItem");
     return(true);
 }
Ejemplo n.º 17
0
 public override void AddItemTile(ItemInventoryTile tile)
 {
     GD.Print("EquipmentSlot - AddItemTile");
     base.AddItemTile(tile);
     OnEquip?.Invoke(GetPayload());
 }
Ejemplo n.º 18
0
 public DragStartPayload(ItemSlot originatingSlot, ItemInventoryTile draggedTile)
 {
     this.originatingSlot = originatingSlot;
     this.draggedTile     = draggedTile;
 }