private void DoTestAfterShowAnswer() { ExperimentState currentStateData = data.States[currentState]; switch (currentStateData.ContentType) { case ExperimentContentType.Number: case ExperimentContentType.NumberWithRandom: NumberAnswerIndicator.gameObject.SetActive(true); NumberInputPanel.gameObject.SetActive(true); NumberAnswerIndicator.Initialize(currentStateData.AnswerTitle, currentStateData.AnswerCount, currentStateData.AnswerMaxLength); EventLogger.LogTestStart(currentState, currentStateData.ContentType); BeepSound.Play(); break; case ExperimentContentType.NumberWithRandomAndNoGuide: NumberAnswerIndicator.gameObject.SetActive(true); NumberInputPanel.gameObject.SetActive(true); TempAnswerText.ShowText(correctAnswers[0].ToString()); NumberAnswerIndicator.Initialize(currentStateData.AnswerTitle, currentStateData.AnswerCount, currentStateData.AnswerMaxLength); EventLogger.LogTestStart(currentState, currentStateData.ContentType); BeepSound.Play(); break; case ExperimentContentType.MultipleSelection: case ExperimentContentType.MultipleSelectionWithRandom: MultipleChoiceInput.gameObject.SetActive(true); MultipleChoiceInput.Initialize(currentStateData.AnswerSet, currentStateData.AnswerCount); EventLogger.LogTestStart(currentState, currentStateData.ContentType); BeepSound.Play(); break; } }
private void DoTest() { currentState++; isShowingGuideText = false; AnswerGuideText.isOkToProceed = false; if (currentState >= 0 && currentState < data.States.Length) { ExperimentState currentStateData = data.States[currentState]; MainGuideTextUI.text = currentStateData.MainGuideText; //제목 설정 ConfirmButton.interactable = false; ConfirmButton.GetComponentInChildren <Text>().text = "확인"; int answerRange; string answerGuideText; switch (currentStateData.ContentType) { case ExperimentContentType.None: AnswerGuideText.gameObject.SetActive(false); NumberAnswerIndicator.gameObject.SetActive(false); NumberInputPanel.gameObject.SetActive(false); MultipleChoiceInput.gameObject.SetActive(false); ConfirmButton.interactable = true; ConfirmButton.GetComponentInChildren <Text>().text = "실험 재시작"; currentState = -1; break; case ExperimentContentType.Number: AnswerGuideText.gameObject.SetActive(false); NumberAnswerIndicator.gameObject.SetActive(true); NumberInputPanel.gameObject.SetActive(true); MultipleChoiceInput.gameObject.SetActive(false); NumberAnswerIndicator.Initialize(currentStateData.AnswerTitle, currentStateData.AnswerCount, currentStateData.AnswerMaxLength); EventLogger.LogTestStart(currentState, currentStateData.ContentType); break; case ExperimentContentType.MultipleSelection: AnswerGuideText.gameObject.SetActive(false); NumberAnswerIndicator.gameObject.SetActive(false); NumberInputPanel.gameObject.SetActive(false); MultipleChoiceInput.gameObject.SetActive(true); MultipleChoiceInput.Initialize(currentStateData.AnswerSet, currentStateData.AnswerCount); EventLogger.LogTestStart(currentState, currentStateData.ContentType); break; //랜덤 정답을 생성해야 하는 경우 case ExperimentContentType.NumberWithRandom: AnswerGuideText.gameObject.SetActive(true); NumberAnswerIndicator.gameObject.SetActive(false); NumberInputPanel.gameObject.SetActive(false); MultipleChoiceInput.gameObject.SetActive(false); //정답 랜덤 생성 answerRange = currentStateData.AnswerMaxLength * 10; correctAnswers = new int[currentStateData.AnswerCount]; answerGuideText = ""; for (int i = 0; i < correctAnswers.Length; i++) { bool isNotOk = true; while (isNotOk) { correctAnswers[i] = Random.Range(1, answerRange - 1); isNotOk = false; for (int j = 0; j < i; j++) { if (correctAnswers[i] == correctAnswers[j]) { isNotOk = false; i--; } } } answerGuideText += correctAnswers[i] + ", "; } isShowingGuideText = true; //위험한 코드 ConfirmButton.interactable = true; //이것도 AnswerGuideText.Initialize(answerGuideText, DoTestAfterShowAnswer); break; case ExperimentContentType.MultipleSelectionWithRandom: AnswerGuideText.gameObject.SetActive(true); NumberAnswerIndicator.gameObject.SetActive(false); NumberInputPanel.gameObject.SetActive(false); MultipleChoiceInput.gameObject.SetActive(false); //정답 랜덤 생성 answerRange = currentStateData.AnswerSet.Length; correctAnswers = new int[currentStateData.AnswerCount]; answerGuideText = ""; for (int i = 0; i < correctAnswers.Length; i++) { bool isNotOk = true; while (isNotOk) { correctAnswers[i] = Random.Range(1, answerRange - 1); isNotOk = false; for (int j = 0; j < i; j++) { if (correctAnswers[i] == correctAnswers[j]) { isNotOk = false; i--; } } } answerGuideText += currentStateData.AnswerSet[correctAnswers[i]] + ", "; } isShowingGuideText = true; //위험한 코드 ConfirmButton.interactable = true; //이것도 AnswerGuideText.Initialize(answerGuideText, DoTestAfterShowAnswer); break; } } }