Пример #1
0
    void IDragHandler.OnDrag(PointerEventData eventData)
    {
        if (!mIsDragging)
        {
            return;
        }

        mDragAreaCurType = GetDragType(eventData.position);

        RefreshDragDisplay(eventData);
    }
Пример #2
0
    void IBeginDragHandler.OnBeginDrag(PointerEventData eventData)
    {
        mDragAreaBeginType = GetDragType(eventData.position);
        mDragAreaCurType   = mDragAreaBeginType;

        RefreshDragDisplay(eventData);

        if (mDragAreaBeginType != DragAreaType.None)
        {
            mIsDragging = true;
            UpdateFractionVisualShow();
        }
    }
Пример #3
0
    private void ResetDrag(bool resetDragRoot)
    {
        StopRoutine();

        mIsDragging        = false;
        mDragAreaBeginType = DragAreaType.None;
        mDragAreaCurType   = DragAreaType.None;

        if (resetDragRoot && dragRoot)
        {
            dragRoot.SetParent(transform, false);
            dragRoot.localPosition = mDragRootDefaultLocalPos;
        }

        if (dragInsideWholeGO)
        {
            dragInsideWholeGO.SetActive(false);
        }
        if (dragInsideFractionGO)
        {
            dragInsideFractionGO.SetActive(false);
        }
        if (dragWholeToFractionGO)
        {
            dragWholeToFractionGO.SetActive(false);
        }
        if (dragFractionToWholeGO)
        {
            dragFractionToWholeGO.SetActive(false);
        }

        if (mCurCardDropWidget)
        {
            mCurCardDropWidget.CardDropHighlightClear();
            mCurCardDropWidget = null;
        }
    }
Пример #4
0
    void IEndDragHandler.OnEndDrag(PointerEventData eventData)
    {
        if (!mIsDragging)
        {
            return;
        }

        mDragAreaCurType = GetDragType(eventData.position);

        //determine action
        switch (mDragAreaCurType)
        {
        case DragAreaType.Whole:
            if (canDragInside)
            {
                if (mDragAreaBeginType == DragAreaType.Fraction)
                {
                    M8.SoundPlaylist.instance.Play(audioFractionSwap, false);

                    numberWidget.FractionToWhole();
                }
            }

            ResetDrag(true);
            UpdateFractionVisualShow();
            break;

        case DragAreaType.Fraction:
            if (canDragInside)
            {
                if (mDragAreaBeginType == DragAreaType.Whole)
                {
                    M8.SoundPlaylist.instance.Play(audioFractionSwap, false);

                    numberWidget.WholeToFraction();
                }
            }

            ResetDrag(true);
            UpdateFractionVisualShow();
            break;

        case DragAreaType.Outside:
            if (canDragOutside)
            {
                //determine if we want to swap or placing to an empty slot
                if (eventData.pointerCurrentRaycast.isValid && eventData.pointerCurrentRaycast.gameObject)
                {
                    var dropWidget = eventData.pointerCurrentRaycast.gameObject.GetComponent <CardDropWidgetBase>();
                    if (dropWidget)
                    {
                        int index = dropWidget.CardDropGetSlotIndex(this);
                        if (index != -1)
                        {
                            SetCurrentCardDrop(dropWidget, index);
                        }
                    }
                    else
                    {
                        var cardWidget = eventData.pointerCurrentRaycast.gameObject.GetComponent <CardWidget>();
                        if (cardWidget && cardWidget.canDragOutside)
                        {
                            if (cardWidget.currentCardDrop && cardWidget.currentCardDropIndex != -1)
                            {
                                SetCurrentCardDrop(cardWidget.currentCardDrop, cardWidget.currentCardDropIndex);     //swap
                            }
                        }
                    }
                }

                ResetDrag(false);
                MoveDragAnchorToOrigin();
            }
            else
            {
                ResetDrag(true);
                UpdateFractionVisualShow();
            }
            break;

        default:
            ResetDrag(true);
            UpdateFractionVisualShow();
            break;
        }
    }