Esempio n. 1
0
        public override void OnUpdate(float deltaTime)
        {
            base.OnUpdate(deltaTime);
            if (selectedId >= 0)
            {
                if (!isDragging && (mouseDownPoint - WMouse.Position).LengthSquared() >= 10f)
                {
                    isDragging = true;
                    dragging_ghost.GetFirst <TextRenderer>().text = listboxComponent[selectedId];
                    AddChild(dragging_ghost);
                }

                if (isDragging)
                {
                    dragging_ghost.transform.Position = WMouse.Position + mouseDownOffset;
                }

                if (WMouse.LeftMouseClickUp())
                {
                    if (isDragging)
                    {
                        OnItemDrop?.Invoke(this, files[selectedId]);
                        RemoveChild(dragging_ghost);
                    }
                    isDragging = false;
                    selectedId = -1;
                }
            }
        }
Esempio n. 2
0
 public void DropItem(int itemIndexToRemove)
 {
     //AudioSource.PlayClipAtPoint(items[itemIndexToRemove].dropSFX, Camera.main.transform.position, 0.5f);
     OnItemDrop?.Invoke(this, new ItemEventArgs()
     {
         itemIndex = itemIndexToRemove
     });
     items.RemoveAt(itemIndexToRemove);
 }
Esempio n. 3
0
        public void DropItem(LootItem itemEntity, Cell cell)
        {
            if (!HasItems(cell))
            {
                CreateItemBag(cell);
            }

            itemEntity.Drop(cell);
            OnItemDrop?.Invoke(itemEntity, cell);
        }
Esempio n. 4
0
        public void OnEndDrag(PointerEventData eventData)
        {
            if (eventData.button != PointerEventData.InputButton.Left)
            {
                return;
            }

            transform.SetParent(parent);
            transform.localPosition = iconInitialPos;

            List <RaycastResult> raycastResults = new List <RaycastResult>();

            graphicRaycaster.Raycast(eventData, raycastResults);
            OnItemDrop?.Invoke(GetComponentInParent <ISlot>(), raycastResults.Select(rr => rr.gameObject).ToList());
        }