コード例 #1
0
    public void OnEndDrag(PointerEventData eventData)
    {
        if (canDrag)
        {
            GetComponent <CanvasGroup>().blocksRaycasts = true;

            if (isSet && dropType == DropType.dropStay)
            {
                GetComponent <CanvasGroup>().blocksRaycasts = false;
                activityAnalytics.AddWrong();
            }
            else if (isSet && dropType == DropType.dropSmooth)
            {
                StartCoroutine(GoToPosition(1, currentPosition));
                GetComponent <CanvasGroup>().blocksRaycasts = false;
                activityAnalytics.AddRight();
            }
            else if (isSet && dropType == DropType.dropSmoothChangeImage)
            {
                StartCoroutine(GoToPosition(1, currentPosition, SettedSprite));
                activityAnalytics.AddRight();
            }
            else
            {
                StartCoroutine(GoToPosition(1, currentPosition));
            }

            Debug.Log(dropType);
        }
    }
コード例 #2
0
 public void AddRight()
 {
     if (activityAnalytics != null)
     {
         activityAnalytics.AddRight();
     }
 }
コード例 #3
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();
            }
        }
    }
コード例 #4
0
    private IEnumerator MatchCards()
    {
        game.AddVictory(true);
        if (activityAnalytics != null)
        {
            activityAnalytics.AddRight();
        }
        yield return(new WaitForSeconds(waitTimeCardFlip));

        card1.PlayCardSound();
        ResetCards();
    }
コード例 #5
0
    public virtual void CheckCorrectItem()
    {
        if (Mathf.Abs(transform.position.x - slot.transform.position.x) <= xLimitDistance &&
            Mathf.Abs(transform.position.y - slot.transform.position.y) <= yLimitDistance)
        {
            dragState = DragStates.notDragging;
            if (slot.GetComponent <DragAndDropSlot>() != null)
            {
                slot.GetComponent <DragAndDropSlot>().checkedSlot = true;
                slot.GetComponent <DragAndDropSlot>().OnCheckedSlot.Invoke();
            }
            GetComponent <Image>().raycastTarget = false;
            draggingObj = null;
            if (refPos)
            {
                refObj.transform.position = this.transform.position;
            }
            this.transform.position        = slot.transform.position;
            GetComponent <Image>().enabled = false;
            if (slotImage != null)
            {
                slotImage.SetActive(true);
            }

            if (playRightSound)
            {
                if (!holdProgress)
                {
                    DragAndDropLogic.instance.MakeProgress();
                }
                if (!truePlayNoRightSound)
                {
                    AudioManager.instance.StopAllSounds();
                    AudioManager.instance.PlaySound(DragAndDropLogic.instance.rightSound);
                    AudioManager.instance.PlayRandomSuccessSound();
                }
            }
            else
            {
                if (!holdProgress)
                {
                    DragAndDropLogic.instance.MakeProgress();
                }
                if (!truePlayNoRightSound)
                {
                    AudioManager.instance.StopAllSounds();
                    AudioManager.instance.PlaySound(DragAndDropLogic.instance.rightSound);
                }
            }
            if (activityAnalytics != null)
            {
                activityAnalytics.AddRight();
            }
        }
        else
        {
            if (playFailSound)
            {
                AudioManager.instance.StopAllSounds();
                AudioManager.instance.PlayRandomFailSound();
            }
            //GetComponent<Animator>().SetTrigger("popDown");
            StartCoroutine(BackToDefaultPosition(this.transform, backAnimVelocity, pivot.transform));
            if (activityAnalytics != null)
            {
                activityAnalytics.AddWrong();
            }
        }
    }