예제 #1
0
        /// <summary>
        /// Updates the new parent group on mouse pointing.
        /// </summary>
        /// <param name="param">Parameter.</param>
        public void UpdateRefHolder(Transform newParentGroupLayout)
        {
            if (parentGroupLayout != null)
            {
                int _childIndex = ChildIndex;

                ///Check for whether its new group
                if (parentGroupLayout != newParentGroupLayout)
                {
                    int _tempCurrentGroupLayoutIndex = parentGroupLayout.transform.GetSiblingIndex();
                    int _tempNewGroupLayoutIndex     = newParentGroupLayout.transform.GetSiblingIndex();

                    ///When card moving to right parent, then -1 will be index else 1
                    _childIndex = _tempCurrentGroupLayoutIndex - _tempNewGroupLayoutIndex;

                    if (_childIndex <= 0)
                    {
                        ///If mvoing right, then set dummy card at 0 position
                        _childIndex = 0;
                    }
                    else
                    {
                        ///If mvoing left, then set dummy card at last position
                        _childIndex = newParentGroupLayout.childCount;
                    }

                    parentGroupLayout = newParentGroupLayout;
                }

                ///set dummy card parent
                if (dummyCardObj.transform.parent != parentGroupLayout)
                {
                    dummyCardObj.transform.SetParent(parentGroupLayout);
                }

                ///set dummy card index
                dummyCardObj.transform.SetSiblingIndex(_childIndex);

                childCount = parentGroupLayout.childCount;

                if (childCount <= 1)
                {
                    return;
                }

                ///check if selectedIndex is less than total childCount
                if (_childIndex + 1 < childCount)
                {
                    ///set the next card of the selected card
                    nextCard = parentGroupLayout.GetChild(_childIndex + 1).GetComponent <RummyCardBehaviour>();
                }

                if (_childIndex - 1 >= 0)
                {
                    ///set the previous card of selected card
                    previousCard = parentGroupLayout.GetChild(_childIndex - 1).GetComponent <RummyCardBehaviour>();
                }
            }
        }
        /// <summary>
        /// Called everytime when mouse enter this gameobject
        /// Its updates the card ref holders to newly pointing rummy group layout
        /// </summary>
        public void OnPointerEnter(PointerEventData eventData)
        {
            if (eventData.pointerDrag == null)
            {
                return;
            }

            GameObject dragObject = eventData.pointerDrag;

            /// On pointing to this instance of BaseDroppable class then update the card ref holders
            RummyCardBehaviour item = dragObject.GetComponent <RummyCardBehaviour>();

            if (item != null)
            {
                item.UpdateRefHolder(this.transform);
            }
        }
예제 #3
0
        /// <summary>
        /// Check for previous card
        /// </summary>
        void CheckWithPreviousCard()
        {
            if (previousCard != null)
            {
                if (transform.position.x < previousCard.transform.position.x)
                {
                    int index = previousCard.transform.GetSiblingIndex();
                    previousCard.transform.SetSiblingIndex(dummyCardObj.transform.GetSiblingIndex());
                    dummyCardObj.transform.SetSiblingIndex(index);

                    nextCard = previousCard;
                    if (index - 1 >= 0)
                    {
                        previousCard = parentGroupLayout.GetChild(index - 1).GetComponent <RummyCardBehaviour>();
                    }
                    else
                    {
                        previousCard = null;
                    }
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Check for next card
        /// </summary>
        void CheckWithNextCard()
        {
            if (nextCard != null)
            {
                if (transform.position.x > nextCard.transform.position.x)
                {
                    int index = nextCard.transform.GetSiblingIndex();
                    nextCard.transform.SetSiblingIndex(dummyCardObj.transform.GetSiblingIndex());
                    dummyCardObj.transform.SetSiblingIndex(index);

                    previousCard = nextCard;
                    if (index + 1 < childCount)
                    {
                        nextCard = parentGroupLayout.GetChild(index + 1).GetComponent <RummyCardBehaviour>();
                    }
                    else
                    {
                        nextCard = null;
                    }
                }
            }
        }