void UpdateCurrentPipeAnswer() { if (game.questionsManager.GetQuestionLivingLetter() == null) { currentPipeAnswer = null; return; } PipeAnswer newPipeAnswer = null; Vector3 letterPosition = game.questionsManager.GetQuestionLivingLetter().letter.contentTransform.position; float pipeDistance = float.PositiveInfinity; for (int i = 0; i < pipeAnswers.Length; i++) { if (pipeAnswers[i].active) { Vector3 pipePosition = pipeAnswers[i].tutorialPoint.position; float newPipeDistance = Vector3.Distance(pipePosition, letterPosition); if (newPipeDistance < pipeDistance) { newPipeAnswer = pipeAnswers[i]; pipeDistance = newPipeDistance; } } } if (pipeDistance > maxLetterDistance) { if (currentPipeAnswer != null) { currentPipeAnswer.StopSelectedAnimation(); currentPipeAnswer = null; } } else { if (currentPipeAnswer != null && currentPipeAnswer != newPipeAnswer) { currentPipeAnswer.StopSelectedAnimation(); currentPipeAnswer = null; } if (currentPipeAnswer == null) { if (newPipeAnswer != null) { newPipeAnswer.PlaySelectedAnimation(); } currentPipeAnswer = newPipeAnswer; } } }
void CheckAnswer() { PipeAnswer pipeAnswer = game.pipesAnswerController.GetCurrentPipeAnswer(); if (pipeAnswer != null && Enabled) { bool isCorrectAnswer = pipeAnswer.IsCorrectAnswer; if (isCorrectAnswer) { game.Context.GetAudioManager().PlaySound(Sfx.LetterHappy); } else { game.Context.GetAudioManager().PlaySound(Sfx.LetterSad); } if (onAnswered != null) { onAnswered(isCorrectAnswer); } pipeAnswer.StopSelectedAnimation(); } }