Esempio n. 1
0
    public void UseItem()
    {
        if (slotEnabled)
        {
            if (InventoryManager.instance.dragging)
            {
                if (hasItem() == false)
                {
                    //ChestOrNormalUse();
                    AddItem(InventoryManager.instance.dragUI.item);
                    InventoryManager.instance.AddItem(item, slotNum);
                    InventoryManager.instance.dragUI.Placed();
                }
            }
            else if (item != null && InventoryManager.instance.dragMode && !isChestSlot)
            {
                DraggableObject drag = InventoryManager.instance.dragUI;
                drag.BeginDrag(item);

                /*
                 * Image dragImage = drag.GetComponent<Image>();
                 * dragImage.sprite = item.icon;
                 * dragImage.color = new Color(dragImage.color.r, dragImage.color.g, dragImage.color.b, 1f);
                 * drag.item = item;*/
                InventoryManager.instance.RemoveItem(slotNum);
                SetInactiveSlot();
                ClearSlot();
            }
            else
            {
                ChestOrNormalUse();
            }
        }
    }
    } //end Update

    public void StartTouch()
    {
        ray = Camera.main.ScreenPointToRay(Gesture.Instance.TouchPosition());

        GameObject scenepause = GameObject.Find("SceneManager");

        gamepausechecking ifpaused = scenepause.GetComponent <gamepausechecking>();

        if (Physics.Raycast(ray, out hit, Mathf.Infinity))
        {
            //Added IF to check for pause state
            if (ifpaused.paused == false)
            {
                if (hit.transform.tag == "Draggable")
                {
                    draggable = hit.transform.GetComponent <DraggableObject>();

                    draggable.BeginDrag(Gesture.Instance.TouchPosition());
                }
            }
        }
    } //end StartTouch