Exemple #1
0
    public override CollectableItem DropWeaponItem(int mountIndex)
    {
        if (mountIndex < 0 || mountIndex >= _weapons.Count)
        {
            return(null);
        }

        InventoryWeaponMountInfo itemMount = _weapons[mountIndex];

        if (itemMount == null || itemMount.Weapon == null)
        {
            return(null);
        }

        InventoryItemWeapon weapon = itemMount.Weapon;

        Vector3 position = _playerPosition != null ? _playerPosition.value : Vector3.zero;

        position += _playerDirection != null ? _playerDirection.value : Vector3.zero;

        var droppedItem = weapon.Drop(position);

        OnItemDropped.Invoke(itemMount.Weapon);
        _weapons[mountIndex].Weapon = null;

        return(droppedItem);
    }
Exemple #2
0
        // Run from unity event
        public void DropItem()
        {
            if (pickedUpItem == null)
            {
                return;
            }

            if (isUsingItem)
            {
                if (pickedUpItem is IUseable usable)
                {
                    usable.EndUse();
                }

                isUsingItem = false;
            }

            pickedUpItem.DropItem(playerGrabTransform);
            OnItemDropped?.Invoke(pickedUpItem);

            Rigidbody body = pickedUpItem.GetComponent <Rigidbody>();

            if (body != null)
            {
                body.velocity = playerMovement.Velocity * throwStrengthMultiplier;
            }

            pickedUpItem = null;
        }
Exemple #3
0
    public override CollectableItem DropAmmoItem(int mountIndex)
    {
        if (mountIndex < 0 || mountIndex >= _foods.Count)
        {
            return(null);
        }

        InventoryAmmoMountInfo itemMount = _ammo[mountIndex];

        if (itemMount == null || itemMount.Ammo == null)
        {
            return(null);
        }

        Vector3 position = _playerPosition != null ? _playerPosition.value : Vector3.zero;

        position += _playerDirection != null ? _playerDirection.value : Vector3.zero;

        var droppedItem = itemMount.Ammo.Drop(position);

        OnItemDropped.Invoke(itemMount.Ammo);
        _ammo[mountIndex].Ammo = null;

        return(droppedItem);
    }
Exemple #4
0
 private void DropItem()
 {
     isCarryingFoyer = false;   // No need to check, what ever we were carrying, right now we are not carrying anything
     isCarryingItem  = false;
     anim.SetBool("IsCarrying", isCarryingItem);
     OnItemDropped?.Invoke(carriedItem);
     carriedItem   = null;
     movementSpeed = normalSpeed;
 }
Exemple #5
0
    public void OnDrop(PointerEventData eventData)
    {
        UI_ItemDrag.Instance.Hide();
        Item item = UI_ItemDrag.Instance.GetItem();

        OnItemDropped?.Invoke(this, new OnItemDroppedEventArgs {
            item = item
        });
    }
        /// <summary>
        /// Sets the dropped Item and calls the itemDroppedEvent
        /// </summary>
        /// <param name="eventData"></param>
        public void OnDrop(PointerEventData eventData)
        {
            if (ItemDragHandler.Instance != null)
            {
                Item item = ItemDragHandler.Instance.GetItem();

                OnItemDropped?.Invoke(this, new OnItemDroppedEventArgs {
                    item = item
                });
            }
        }
 private void DropItem(InventorySlot slot)
 {
     if (!slot.SlotIsTaken)
     {
         return;
     }
     else
     {
         if (slot.ObjectData.ItemCategory == "Seeds")
         {
             Debug.Log("Seed dropped");
             OnSeedDropped?.Invoke(slot.ObjectData);
         }
         else
         {
             GameObject tile   = PlayerController.Instance.FindStandingTile();
             float      height = tile.GetComponent <Renderer>().bounds.size.y;
             Instantiate(slot.ObjectData.Prefab, new Vector3(PlayerController.Instance.GetPlayerPosition().position.x, tile.transform.position.y + height / 2, tile.transform.position.z), transform.rotation);
             OnItemDropped?.Invoke(slot.ObjectData);
             RemoveSingleItem(m_SelectedSlot);
         }
     }
 }
 public virtual void DropItem(PlayerController controller)
 {
     OnItemDropped?.Invoke();
 }
Exemple #9
0
 public static void RaiseOnItemDropped()
 {
     OnItemDropped?.Invoke();
 }
 public static void FireItemDropped(TrinityItem item)
 {
     Core.Logger.Log(LogCategory.ItemEvents, $"ItemDropped {item.Name}");
     OnItemDropped?.Invoke(item);
 }
    public override void OnDrop(PointerEventData eventData)
    {
        ItemDragHandler itemDragHandler = eventData.pointerDrag.GetComponent <ItemDragHandler>();

        if (itemDragHandler == null)
        {
            return;
        }

        InventorySlot inventorySlot = itemDragHandler.ItemSlotUI as InventorySlot;

        // If item is an equipment
        if (inventorySlot != null && inventorySlot.SlotItem.IsEquipment == true)
        {
            // Check if inventory slot is a chest slot and the item dropped is also a chest slot.
            if (inventorySlotType == InventorySlotType.Chest && inventorySlot.SlotItem.equipmentType == HotbarItem.EquipmentType.Chest)
            {
                Debug.Log("Testing chest slot");
                slotItem = inventorySlot.ItemSlot.item;
                OnItemDropped?.Invoke(this, new OnItemDroppedEventArgs {
                    item = slotItem
                });
                inventory.ItemContainer.SwapEquip(itemDragHandler.ItemSlotUI.SlotIndex, SlotIndex);
                Debug.Log(slotItem.name);
                return;
            }
            // Check if inventory slot is a Head slot and the item dropped is also a Head slot.
            else if (inventorySlotType == InventorySlotType.Head && inventorySlot.SlotItem.equipmentType == HotbarItem.EquipmentType.Head)
            {
                slotItem = inventorySlot.ItemSlot.item;
                OnItemDropped?.Invoke(this, new OnItemDroppedEventArgs {
                    item = slotItem
                });
                inventory.ItemContainer.SwapEquip(itemDragHandler.ItemSlotUI.SlotIndex, SlotIndex);
                Debug.Log(slotItem.name);
                return;
            }
            // Check if inventory slot is a legs slot and the item dropped is also a legs slot.
            else if (inventorySlotType == InventorySlotType.Legs && inventorySlot.SlotItem.equipmentType == HotbarItem.EquipmentType.Legs)
            {
                slotItem = inventorySlot.ItemSlot.item;
                OnItemDropped?.Invoke(this, new OnItemDroppedEventArgs {
                    item = slotItem
                });
                inventory.ItemContainer.SwapEquip(itemDragHandler.ItemSlotUI.SlotIndex, SlotIndex);
                Debug.Log(slotItem.name);
                return;
            }
            // Check if inventory slot is a weapon slot and the item dropped is also a weapon slot.
            else if (inventorySlotType == InventorySlotType.Weapon && inventorySlot.SlotItem.equipmentType == HotbarItem.EquipmentType.Weapon)
            {
                slotItem = inventorySlot.ItemSlot.item;
                OnItemDropped?.Invoke(this, new OnItemDroppedEventArgs {
                    item = slotItem
                });
                inventory.ItemContainer.SwapEquip(itemDragHandler.ItemSlotUI.SlotIndex, SlotIndex);
                Debug.Log(slotItem.name);
                return;
            }
            else if (inventorySlotType == InventorySlotType.Inventory)
            {
                Debug.Log("Inventory slot: inventory");
                inventory.ItemContainer.SwapEquip(itemDragHandler.ItemSlotUI.SlotIndex, SlotIndex);
                //inventory.playerEquipment.removeDisplayedEquipment();
                return;
            }
            else
            {
                return;
            }

            //return;
        }
        if ((itemDragHandler.ItemSlotUI as InventorySlot) != null & !CheckIfEquipmentSlot(inventorySlotType))
        {
            inventory.ItemContainer.Swap(itemDragHandler.ItemSlotUI.SlotIndex, SlotIndex);
            //return;
        }

        // If inventory slot && item is Equipment
        // if: Compare Head
        // Do something
        // if: Compare Chest
        // Do Something
        // if: Compare Legs
        // Do something
        // if: Compare Weapon
        // Do Something
    }