Esempio n. 1
0
        public void OnDrop(PointerEventData eventData)
        {
            ItemCard card = eventData.pointerDrag.GetComponent <ItemCard>();

            if (card != null)
            {
                bool IsCorrect = IsEmpty && (card.Category == ChestItemCategory || ChestItemCategory == ItemCardCategory.Empty);
                if (IsCorrect)
                {
                    currentCard       = card;
                    ChestItemCategory = card.Category;
                    eventData.pointerDrag.transform.SetParent(ImageSlot.transform);

                    RectTransform rect = eventData.pointerDrag.GetComponent <RectTransform>();

                    rect.anchoredPosition = new Vector2(0, 0);
                    rect.anchorMin        = new Vector2(0, 0);
                    rect.anchorMax        = new Vector2(1, 1);

                    rect.offsetMin = new Vector2(0, 0);
                    rect.offsetMax = new Vector2(0, 0);
                    card.DisableDrag();
                }

                if (OnCardDrop != null)
                {
                    OnCardDrop.Invoke(card, IsCorrect);
                }
            }
        }
Esempio n. 2
0
 public void StopDrag()
 {
     GetComponent <Collider>().enabled = true;
     OnCardDrop?.Invoke(this);
 }