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); } } }
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(); } }