Exemple #1
0
        void OnCardDragEnd(CardWidget cardWidget, PointerEventData pointerEventData)
        {
            SlotClearHighlights();

            //check if pointer is in slot
            if (pointerEventData != null)
            {
                SlotInfo slot = null;

                var hit = pointerEventData.pointerCurrentRaycast;
                if (hit.isValid && hit.gameObject)
                {
                    slot = GetSlot(hit.gameObject);
                }

                if (slot != null && !slot.isFilled)
                {
                    //can we fill it?
                    if (CanFill(cardWidget.cardData))
                    {
                        if (!string.IsNullOrEmpty(sfxCorrect))
                        {
                            M8.SoundPlaylist.instance.Play(sfxCorrect, false);
                        }

                        //fill slot and remove from deck
                        slot.Fill(cardWidget.cardData);

                        deckWidget.Remove(cardWidget);

                        mCurScore  += GameData.instance.GetScore(mErrorCount, mSlotCount > 1);
                        mErrorCount = 0;
                    }
                    else   //error
                    {
                        if (!string.IsNullOrEmpty(sfxWrong))
                        {
                            M8.SoundPlaylist.instance.Play(sfxWrong, false);
                        }

                        slot.Error();

                        cardWidget.Return();

                        mErrorCount++;
                    }
                }
                else
                {
                    cardWidget.Return();
                }
            }
        }