Exemplo n.º 1
0
    public void OnEndDrag(PointerEventData data)
    {
        if (_slotManger.overSlot)
        {
            Debug.Log("in");
            _slotManger.ReturnItemToLastSlot(_slotManger.lastSlotNumber);
        }
        else if (!_slotManger.outSideInvenotry)
        {
            Debug.Log("out");
            _slotManger.ReturnItemToLastSlot(_slotManger.originSlot);
        }
        else
        {                //use item
            Vector2      ray = Camera.main.ScreenPointToRay(Input.mousePosition).origin;
            RaycastHit2D hit = Physics2D.Raycast(ray, Vector3.forward, 20, _slotManger.layer);
            Debug.Log(hit);

            if (hit.transform != null)
            {
                if (hit.transform.tag == "Player")
                {
                    user.UseItem(inventory.draggedItem, inventory.draggingIndex);
                }
                else

                {
                    _slotManger.ReturnItemToLastSlot(_slotManger.originSlot);
                }
            }                           //inventory.closeDraggedItem ();
            else
            {
                _slotManger.ReturnItemToLastSlot(_slotManger.originSlot);
            }
        }
        //else
        //	Debug.Log("outside");

        //Debug.Log("maybe");
        //if (inventory.draggingItem && inventory.Items[slotNumber].itemName == null ) {
        //	inventory.closeDraggedItem ();
        //	inventory.Items [inventory.draggingIndex] = inventory.Items [slotNumber];
        //	inventory.Items [slotNumber] = inventory.draggedItem;
        //Debug.Log("returnItem");
        //_slotManger.updateCheck = true;
        //user.UseItem (inventory.Items [slotNumber], slotNumber);
        //}
        //else
        //{

        //	Debug.Log("useItem");
        //	user.UseItem(inventory.draggedItem, inventory.draggingIndex);
        //}
        //if (inventory.draggingItem) {
        //	inventory.closeDraggedItem ();
        //	inventory.Items [inventory.draggingIndex] = inventory.Items [inventory.dragOn];
        //	inventory.Items [inventory.dragOn] = inventory.draggedItem;
        //}
    }
Exemplo n.º 2
0
 public void removeItem(int ID, int slot)
 {
     if (ID > 0)
     {
         Debug.Log(draggedItem.itemName);
         Debug.Log(draggedItem.itemValue);
         if (draggedItem.itemStackable && draggedItem.itemValue > 1)
         {
             draggedItem.itemValue--;
             slotmanger.ReturnItemToLastSlot(slotmanger.originSlot);
         }
         else
         {
             Items [slot] = new Item();
         }
     }
 }
Exemplo n.º 3
0
    private void FairyCase(Fairy UseFairy, int slot)
    {
        switch (UseFairy.fairyType)
        {
        case Fairy.FairyType.Heal:
            //Debug.Log(UseFairy.ActiveFairy);

            if (!UseFairy.ActiveFairy && !UseFairy.CooldownActive)
            {
                inventory.removeItem(UseFairy.itemID, slot);
                inventory.CountDownTimer(0, UseFairy);
                UseFairy.ActiveFairy = true;
                StartCoroutine(HealFairy(UseFairy));
            }
            else
            {
                slotmanger.ReturnItemToLastSlot(slotmanger.originSlot);
            }

            break;

        case Fairy.FairyType.GearProtection:
            if (!UseFairy.ActiveFairy && !UseFairy.CooldownActive)
            {
                inventory.removeItem(UseFairy.itemID, slot);
                inventory.CountDownTimer(1, UseFairy);
                UseFairy.ActiveFairy = true;
            }
            else
            {
                slotmanger.ReturnItemToLastSlot(slotmanger.originSlot);
            }
            break;

        case Fairy.FairyType.DefenseBoost:
            if (!UseFairy.ActiveFairy && !UseFairy.CooldownActive)
            {
                inventory.removeItem(UseFairy.itemID, slot);
                inventory.CountDownTimer(2, UseFairy);
                UseFairy.ActiveFairy = true;
            }
            else
            {
                slotmanger.ReturnItemToLastSlot(slotmanger.originSlot);
            }
            break;

        case Fairy.FairyType.AttackBoost:
            if (!UseFairy.ActiveFairy && !UseFairy.CooldownActive)
            {
                inventory.removeItem(UseFairy.itemID, slot);
                inventory.CountDownTimer(3, UseFairy);
                UseFairy.ActiveFairy = true;
                StartCoroutine(AttackFairy(UseFairy));
            }
            else
            {
                slotmanger.ReturnItemToLastSlot(slotmanger.originSlot);
            }
            break;
        }
    }