public void SetController(OpenDoorRound controller) { _controller = controller; for (int i = 0; i < _answerButtons.Length; i++) { int index = i; _answerButtons[i].onClick.RemoveAllListeners(); _answerButtons[i].onClick.AddListener(() => { Debug.LogFormat("Trying to show answer {0}", index); _answerButtons[index].interactable = false; _controller.CorrectAnswer(index); }); _answerButtons[i].interactable = false; } _startTimerButton.onClick.AddListener(_controller.StartTimer); _startTimerButton.onClick.AddListener(SetStateToWaitingForAnswer); _playerPassedButton.onClick.AddListener(_controller.TeamPassed); _nextQuestionButton.onClick.AddListener(_controller.NextQuestion); _nextQuestionButton.onClick.AddListener(SetStateToWaitingForQuestionPicked); for (int i = 0; i < _questionButtons.Length; i++) { int index = i; _questionButtons[i].onClick.RemoveAllListeners(); _questionButtons[i].onClick.AddListener(() => { Debug.LogFormat("Trying to set question {0}", index); _questionButtons[index].interactable = false; _controller.NextQuestion(index); }); _questionButtons[i].onClick.AddListener(SetStateWaitingForStartTimer); _questionButtons[i].interactable = true; } _questionCanvas.interactable = false; _controller.OnWaitingForNextQuestionPrompt += SetStateToWaitingForNextQuestion; _controller.OnWaitingForStartTimer += SetStateWaitingForStartTimer; }
public override void SetAnswers(string question, int[] answerScores, string[] answers) { base.SetAnswers(question, answerScores, answers); for (int i = 0; i < answers.Length; i++) { base.ShowAnswer(i, false); int index = i; _answerButtons[i].onClick.RemoveAllListeners(); _answerButtons[i].onClick.AddListener(() => { Debug.LogFormat("Trying to show answer {0}", index); _answerButtons[index].interactable = false; _controller.CorrectAnswer(index); }); _answerButtons[i].interactable = true; _answerButtonsCanvas.interactable = false; } _question.text = question; _playerView.SetAnswers(question, answerScores, answers); }