Ejemplo n.º 1
0
        public void OnEndDrag(PointerEventData eventData)
        {
            var invrect = Inventory.GetComponent <RectTransform>();

            if (!InCraft)
            {
                List <RaycastHit2D> hit = Physics2D.GetRayIntersectionAll(Camera.main.ScreenPointToRay(Input.mousePosition)).ToList();
                if (hit.Any(h => h.collider == Crafter.GetComponentInParent <Collider2D>()))
                {
                    if (Crafter.AddItem(Item))
                    {
                        OnDrop?.Invoke();
                    }
                    else
                    {
                        // display msg
                    }
                }
            }
            else if (InCraft && RectTransformUtility.RectangleContainsScreenPoint(invrect, Input.mousePosition))
            {
                if (Inventory.AddItem(Item))
                {
                    OnDrop?.Invoke();
                }
                else
                {
                    // display msg
                }
            }
            _image.transform.localPosition = Vector3.zero;
        }
Ejemplo n.º 2
0
    void Start()
    {
        InventoryView PlayerInventory = GetComponentInChildren <InventoryView>();

        if (PlayerInventory != null)
        {
            PlayerInventory.AddItem(new Item(Item.Type.Water), 15);
            // PlayerInventory.AddItem(new Item(Item.Type.Water), 13);
            // PlayerInventory.AddItem(new Item(Item.Type.Water), 62);
        }
    }