Esempio n. 1
0
    //handles drop into non-slot
    public void OnEndDrag(PointerEventData eventData)
    {
        itemBeingDragged = null;
        GetComponent <CanvasGroup>().blocksRaycasts = true;

        if (transform.parent == startParent)
        {
            if (!abilityBeingDraggedSlot.isBasicBarSlot) //if the ability being draged is not from the basic slot
            {
                //Debug.Log("non basic dragged to non slot");
                //Debug.Log(abilityBeingDraggedSlot.abilityId);
                Transform treeSpot = tp.FindSlotById(abilityBeingDraggedSlot.abilityId).transform;
                transform.SetParent(treeSpot, false);
                transform.position = treeSpot.position;
                if (abilityBeingDraggedSlot.isBarSlot) //reset ability bar
                {
                    tp.updateSpecialAbilities(abilityBeingDraggedSlot.spot, new EmptyAbility());
                }
            }
            else
            {
                //Debug.Log("basic being draggeed somewhere");
                transform.position = startPosition;
            }
        }
        // transform.parent.gameObject.GetComponent<SlotScript>().ability = ability;
    }
Esempio n. 2
0
    //handles drop into slots
    public void OnDrop(PointerEventData eventData)
    {
        if (isValidDrop())
        {
            // Debug.Log("Good Drop");
            if (DragHandler.abilityBeingDraggedSlot.isBarSlot)
            {
                // Debug.Log("leaving bar slot");
                tp.updateSpecialAbilities(DragHandler.abilityBeingDraggedSlot.spot, new EmptyAbility());
            }

            if (item)
            {
                // Debug.Log("Something in the slot");
                if (isBarSlot)
                {
                    // Debug.Log("Swap");
                    if (ability == null)
                    {
                        // ability = item.get
                    }
                    Transform treeSlot = tp.FindSlotById(ability.id).transform;
                    ability = DragHandler.abilityBeingDraggedSlot.ability;
                    transform.GetChild(0).SetParent(treeSlot, false);
                    DragHandler.itemBeingDragged.transform.SetParent(transform);
                    if (!isBasicBarSlot)
                    {
                        //  Debug.Log("update non basic");
                        tp.updateSpecialAbilities(spot, (ISpecial)ability);
                    }
                    else
                    {
                        //  Debug.Log(ability);
                        ability = DragHandler.abilityBeingDraggedSlot.ability;
                        //   Debug.Log(ability);
                        tp.updateBasicAbility((IBasic)ability);
                    }
                }
                else
                {
                    Transform treeSlot = tp.FindSlotById(DragHandler.abilityBeingDraggedSlot.abilityId).transform;
                    DragHandler.itemBeingDragged.transform.SetParent(treeSlot, false);
                }
            }
            else
            {
                // Debug.Log("nothing in the spot");
                if (isBarSlot)
                {
                    ability = DragHandler.abilityBeingDraggedSlot.ability;
                    if (isBasicBarSlot)
                    {
                        // Debug.Log("Shouln't ever come here??");
                        tp.updateBasicAbility((IBasic)ability);
                    }
                    else
                    {
                        tp.updateSpecialAbilities(spot, (ISpecial)ability);
                    }
                    abilityId = DragHandler.abilityBeingDraggedSlot.abilityId;
                    DragHandler.itemBeingDragged.transform.SetParent(transform, false);
                }
                else
                {
                    Transform treeSlot = tp.FindSlotById(DragHandler.abilityBeingDraggedSlot.abilityId).transform;
                    // Debug.Log("moving to slot of ability with id" + DragHandler.abilityBeingDraggedSlot.abilityId);
                    DragHandler.itemBeingDragged.transform.SetParent(treeSlot, false);
                    if (DragHandler.abilityBeingDraggedSlot.isBarSlot)
                    {
                        // Debug.Log("moving from bar");
                        tp.updateSpecialAbilities(DragHandler.abilityBeingDraggedSlot.spot, new EmptyAbility());
                    }
                }
            }
        }
        else
        {
            //goes back to parent, in DragHandler
            Debug.Log("Bad Drop");
        }
    }