Esempio n. 1
0
        // Here is the event callback of an item drag
        public void OnDrag(PointerEventData eventData)
        {
            //Hide cursor when dragging
            Cursor.visible = false;

            dragEventData = eventData;
            drag          = true;

            //Getting gameobject that we hover on
            var hoveredGameObject = eventData.pointerCurrentRaycast.gameObject;

            if (hoveredGameObject != null)
            {
                //If we have not an gridslot hit and got inventoryitem component
                if (hoveredGameObject.GetComponent <InventoryItem>() != null && hoveredGameObject.GetComponent <GridSlot>() == null)
                {
                    inventory.DrawRegularSlotsColors();

                    var inv_item = hoveredGameObject.GetComponent <InventoryItem>();

                    if (inv_item.item.id != item.id)
                    {
                        //Look here we check if we should hovered item blocked fully or not
                        //If

                        if (inv_item.x > x || inv_item.y > y)
                        {
                            inventory.DrawColorsForHoveredSlots(inv_item.x, inv_item.y, inv_item.width, inv_item.height);
                        }
                        else if (inv_item.x == x && inv_item.y == y)
                        {
                            inventory.DrawColorsForHoveredSlots(inv_item.x, inv_item.y, width, height);
                        }
                        else
                        {
                            inventory.DrawColorsForHoveredSlots(inv_item.x, inv_item.y, width, height);
                        }
                    }
                    else
                    {
                        inventory.DrawColorForStackableHoveredSlots(inv_item.x, inv_item.y, inv_item.width, inv_item.height);
                    }
                }
                else if (hoveredGameObject.GetComponent <InventoryItem>() == null && hoveredGameObject.GetComponent <GridSlot>() != null)
                {
                    if (hoveredSlot != hoveredGameObject.GetComponent <GridSlot>())
                    {
                        hoveredSlot = hoveredGameObject.GetComponent <GridSlot>();
                    }
                    else if (hoveredSlot == hoveredGameObject.GetComponent <GridSlot>() && hoveredGameObject.GetComponent <GridSlot>().equipmentPanel != null)
                    {
                        inventory.DrawRegularSlotsColors();
                        inventory.DrawColorsForHoveredSlots(CalculateShiftedAxes().x, CalculateShiftedAxes().y, width, height);
                    }
                    else if (hoveredGameObject.GetComponent <GridSlot>().equipmentPanel == null)
                    {
                        inventory.DrawRegularSlotsColors();
                        inventory.DrawColorsForHoveredSlots(CalculateShiftedAxes().x, CalculateShiftedAxes().y, width, height);
                    }
                }
            }
        }