示例#1
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().PlayLetterData(letterData);
                }
            }
        }
 public void Reset()
 {
     SetState(State.NonInteractive);
     SetIsKinematic(true);
     SetRotation(new Vector3(0, 180, 0));
     droppedZone         = null;
     correctDropZone     = null;
     isSubjectOfTutorial = false;
 }
示例#4
0
        public void OnTriggerExit(Collider collider)
        {
            if (isChosen)
            {
                isChosen       = false;
                chosenDropZone = null;
            }

            Unhighlight();
        }
示例#5
0
        public void VerifyLetters()
        {
            for (int i = 0; i < lettersInOrder.Count; i++)
            {
                DropZoneController dropZone = dropZoneControllers[i];
                if (dropZone.droppedLetter == null ||
                    dropZone.droppedLetter.GetLetter().Id != lettersInOrder[i].Id ||
                    Mathf.Abs(dropZone.droppedLetter.transform.rotation.z) > 0.1f)
                {
                    for (int j = 0; j < lettersInOrder.Count; j++)
                    {
                        SeparateLetterController letter = SeparateLettersSpawnerController.instance.separateLetterControllers[j];
                        letter.SetIsSubjectOfTutorial(roundNumber == 0 && letter == dropZone.correctLetter);
                    }

                    return;
                }
            }

            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();
            }
        }
示例#7
0
        public void ShowDropZones()
        {
            int   numLetters             = lettersInOrder.Count;
            bool  isEven                 = numLetters % 2 == 0;
            float dropZoneWidthWithSpace = Constants.DROP_ZONE_WIDTH + 1f;
            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;
                dropZoneController.SetPosition(dropZonePosition);
            }

            for (int i = numLetters; i < dropZoneControllers.Length; i++)
            {
                dropZoneControllers[i].Disable();
            }
        }
 public void SetCorrectDropZone(DropZoneController dropZoneController)
 {
     correctDropZone = dropZoneController;
 }
 public void SetDropZone(DropZoneController dropZone)
 {
     this.dropZone = dropZone;
 }