Пример #1
0
    public void OnDrop(PointerEventData eventData)
    {
        RectTransform invPanel = transform as RectTransform;

        if (!RectTransformUtility.RectangleContainsScreenPoint(invPanel,
                                                               Input.mousePosition))
        {
            InventoryItemBase item = eventData.pointerDrag.gameObject.GetComponent <ItemDragHandler>().Item;
            if (item != null)
            {
                _Inventory.RemoveItem(item);
                item.OnDrop();
            }
        }
    }
Пример #2
0
    public void DropCurrentItem()
    {
        _animControl.SetTrigger("tr_drop");

        GameObject goItem = (_InventoryItemBase as MonoBehaviour).gameObject;

        Inventory.RemoveItem(_InventoryItemBase);


        // Throw animation
        Rigidbody rbItem = goItem.AddComponent <Rigidbody>();

        if (rbItem != null)
        {
            rbItem.AddForce(transform.forward * 2.0f, ForceMode.Impulse);

            Invoke("DoDropItem", 0.25f);
        }
    }