Exemplo n.º 1
0
        public void ShowDropZones()
        {
            int   numLetters             = PromptLettersInOrder.Count;
            bool  isEven                 = numLetters % 2 == 0;
            float dropZoneWidthWithSpace = Constants.DROP_ZONE_WIDTH + 0.6f;
            float dropZoneXStart         = isEven ? numLetters / 2 - 0.5f : Mathf.Floor(numLetters / 2);

            dropZoneXStart *= dropZoneWidthWithSpace;

            for (int i = 0; i < numLetters; i++)
            {
                DropZoneController dropZoneController = dropZoneControllers[i];
                dropZoneController.Enable();

                Vector3 dropZonePosition = dropZoneController.transform.position;
                dropZonePosition.x = dropZoneXStart - i * dropZoneWidthWithSpace;
                if (!LanguageSwitcher.LearningRTL)
                {
                    dropZonePosition.x *= -1;
                }
                dropZoneController.SetPosition(dropZonePosition);
            }

            for (int i = numLetters; i < dropZoneControllers.Length; i++)
            {
                dropZoneControllers[i].Disable();
            }
        }
Exemplo n.º 2
0
 public void OnTriggerEnter(Collider collider)
 {
     Throb();
     isChosen       = true;
     chosenDropZone = this;
     Highlight();
 }
        private void OnPointerDown()
        {
            if (state == State.Draggable || state == State.Dropped)
            {
                Ray ray = Camera.main.ScreenPointToRay(MixedLettersConfiguration.Instance.Context.GetInputManager().LastPointerPosition);

                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, Mathf.Infinity) && hit.collider == boxCollider)
                {
                    SetState(State.Dragging);
                    SetIsKinematic(true);

                    if (transform.position.z != DropZoneController.DropZoneZ)
                    {
                        Vector3 position = transform.position;
                        position.z         = DropZoneController.DropZoneZ;
                        transform.position = position;
                    }

                    if (droppedZone != null)
                    {
                        droppedZone.SetDroppedLetter(null);
                        droppedZone = null;
                    }

                    MixedLettersConfiguration.Instance.Context.GetAudioManager().PlayVocabularyData(letterData, true);
                }
            }
        }
 public void Reset()
 {
     SetState(State.NonInteractive);
     SetIsKinematic(true);
     SetRotation(new Vector3(0, 180, 0));
     droppedZone         = null;
     correctDropZone     = null;
     isSubjectOfTutorial = false;
 }
Exemplo n.º 5
0
        public void OnTriggerExit(Collider collider)
        {
            if (isChosen)
            {
                isChosen       = false;
                chosenDropZone = null;
            }

            Unhighlight();
        }
Exemplo n.º 6
0
        public void VerifyLetters()
        {
            bool isValid = true;

            for (int i = 0; i < PromptLettersInOrder.Count; i++)
            {
                DropZoneController dropZone = dropZoneControllers[i];

                if (dropZone.droppedLetter == null ||
                    !MixedLettersConfiguration.Instance.IsDataMatching(dropZone.droppedLetter.GetLetter(), PromptLettersInOrder[i]) ||
                    Mathf.Abs(dropZone.droppedLetter.transform.rotation.z) > 0.1f)
                {
                    if (isValid)
                    {
                        for (int j = 0; j < PromptLettersInOrder.Count; j++)
                        {
                            SeparateLetterController letter = SeparateLettersSpawnerController.instance.separateLetterControllers[j];
                            letter.SetIsSubjectOfTutorial(
                                roundNumber == 0 && TutorialEnabled &&
                                letter == dropZone.correctLetter);
                        }
                    }

                    isValid = false;
                }
                else
                {
                    if (dropZone.gameObject.activeInHierarchy)
                    {
                        dropZone.droppedLetter.DisableCollider();
                        dropZone.Disable();
                        dropZone.DisableCollider();
                        dropZone.ShowGreenTick();
                    }
                }
            }

            if (isValid)
            {
                for (int i = 0; i < PromptLettersInOrder.Count; i++)
                {
                    dropZoneControllers[i].droppedLetter.EnableCollider();
                }

                OnRoundWon();
            }
        }
        private void OnPointerUp()
        {
            if (state == State.Dragging)
            {
                if (DropZoneController.chosenDropZone != null)
                {
                    droppedZone = DropZoneController.chosenDropZone;
                    droppedZone.SetDroppedLetter(this);
                    transform.position = droppedZone.transform.position;
                    DropZoneController.chosenDropZone = null;

                    SetState(State.Dropped);
                }

                else
                {
                    SetIsKinematic(false);
                    SetState(State.Draggable);
                }

                MixedLettersGame.instance.VerifyLetters();
            }
        }
 public void SetCorrectDropZone(DropZoneController dropZoneController)
 {
     correctDropZone = dropZoneController;
 }
Exemplo n.º 9
0
 public void SetDropZone(DropZoneController dropZone)
 {
     this.dropZone = dropZone;
 }