Пример #1
0
        private void Clear()
        {
            if (icon != null)
            {
                Destroy(icon);
            }

            draggedItem = null;
            icon        = null;
            sourceCell  = null;

            GetSlot()?.SetButtonEnable(true);
        }
Пример #2
0
        protected void MoveToExistingItem(Droppable cell)
        {
            var itemSlot        = cell.GetSlot();
            var containingCells = FindCells(itemSlot.CurrentItemCode);

            foreach (var containingCell in containingCells)
            {
                if (!containingCell.Equals(cell))
                {
                    itemSlot.Add(containingCell.GetSlot());
                }
            }
        }
Пример #3
0
        private void EnableAction(Droppable cell)
        {
            var cellSlot = cell.GetSlot();

            if (cell.Type == Droppable.CellType.TrashBin)
            {
                cellSlot.ClearActions();
            }
            else if (Inventory.ContainerOpen || BaseShopUI.isOpen || CookingEntity.Open)
            {
                cellSlot.SetSelfAction(openBagSlotAction);
            }
            else
            {
                cellSlot.SetUseAction();
            }
        }
Пример #4
0
        public void OnBeginDrag(PointerEventData eventData)
        {
            if (CookingHandler.Ongoing)
            {
                return;
            }

            if (!GameLibOfMethods.doingSomething && GameLibOfMethods.canInteract && !GameLibOfMethods.cantMove)
            {
                sourceCell  = GetCell();
                draggedItem = this;

                icon = new GameObject();

                icon.name = "Icon";
                Image myImage = GetComponentsInChildren <Image>()[1];
                icon.transform.SetParent(canvas.transform);
                myImage.raycastTarget = false;                                          // Disable icon's raycast for correct drop handling
                Image iconImage = icon.AddComponent <Image>();
                iconImage.raycastTarget = false;
                iconImage.sprite        = myImage.sprite;
                RectTransform iconRect = icon.GetComponent <RectTransform>();
                // Set icon's dimensions
                RectTransform myRect = GetComponent <RectTransform>();
                iconRect.pivot            = new Vector2(0.5f, 0.5f);
                iconRect.anchorMin        = new Vector2(0.5f, 0.5f);
                iconRect.anchorMax        = new Vector2(0.5f, 0.5f);
                iconRect.sizeDelta        = new Vector2(myRect.rect.width, myRect.rect.height);
                iconImage.preserveAspect  = true;
                icon.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);

                GetSlot()?.SetButtonEnable(false);

                Inventory.SFX(Inventory.Sound.StartDrag);
            }
            else
            {
                GameLibOfMethods.CreateFloatingText("You are busy, can't rearrange inventory now!", 2);
            }
        }
Пример #5
0
 private void SetAction(Droppable cell)
 {
     cell.GetSlot().SetSelfAction(Inventory.PlaceOnBag);
 }