void AnswerCheck() { T.start = false; T.Inturupt = true; if (swipeDirection == SwpipeDirection.UP && CurrentQuestion.CorrectAnswer == CorrectAnswerDirection.FirstAnswer) { StartCoroutine(AnswerDisplay(true, true)); } else if (swipeDirection == SwpipeDirection.Down && CurrentQuestion.CorrectAnswer == CorrectAnswerDirection.SecondAnswer) { StartCoroutine(AnswerDisplay(true, false)); } else { if (swipeDirection == SwpipeDirection.UP) { StartCoroutine(AnswerDisplay(false, true)); } else { StartCoroutine(AnswerDisplay(false, false)); } } swipeDirection = SwpipeDirection.None; }
//update used in swipe void Update() { TimerText.text = T.CurrentTime.ToString(); if (T.TimeUp) { if (T.PlaySound) { AnswerCheck(); SoundController.PlaySoundTimeUP(); T.PlaySound = false; } } if (!CoroutineRunning) { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); switch (touch.phase) { case TouchPhase.Began: startPos = touch.position; directionChosen = false; break; case TouchPhase.Moved: direction = touch.position - startPos; break; case TouchPhase.Ended: directionChosen = true; break; } } if (directionChosen) { if (direction.y > SwipeThreshold) { swipeDirection = SwpipeDirection.UP; } else if (direction.y < -SwipeThreshold) { swipeDirection = SwpipeDirection.Down; } direction.y = 0f; directionChosen = false; if (swipeDirection != SwpipeDirection.None) { AnswerCheck(); } } } if (AllQAnswered) { DoNextQuestions(); } }