Пример #1
0
    public void OnDrop(PointerEventData eventData)
    {
        GameObject droppedObject = eventData.pointerDrag;

        if (droppableObjects.Contains(droppedObject))
        {
            DragBehaviour dragBehaviour = droppedObject.GetComponent <DragBehaviour>();

            if (dragBehaviour.GetCanDrag())
            {
                dragBehaviour.ObjectIsSet((positionSnapList[droppableObjects.IndexOf(droppedObject)].position));
                dragBehaviour.PlayRightAudio();


                if (isSortedAudio)
                {
                    droppedObject.GetComponent <Image>().sprite        = droppedObject.GetComponent <DragBehaviour>().SettedSprite;
                    droppedObject.GetComponent <Image>().raycastTarget = false;
                    dragBehaviour.PlaySortedAudio();
                }

                if (scale)
                {
                    if (ScaleTo != Vector3.zero)
                    {
                        droppedObject.GetComponent <RectTransform>().localScale = ScaleTo;
                    }
                    else
                    {
                        droppedObject.GetComponent <RectTransform>().localScale = new Vector3(0.3f, 0.3f, 0.3f);
                    }
                }

                OnComplete.Invoke();

                // particleManager.StartParticles();
                if (activityAnalytics != null)
                {
                    activityAnalytics.AddRight();
                }
                game.AddVictory(true);
            }
        }
        else
        {
            if (activityAnalytics != null)
            {
                activityAnalytics.AddWrong();
            }
            if (randomFail)
            {
                droppedObject.GetComponent <DragBehaviour>().PlayRandomWrongAudio();
            }
            else
            {
                droppedObject.GetComponent <DragBehaviour>().PlayWrongAudio();
            }
        }
    }