// Get possible responses and update response text objects private IEnumerator UpdateResponseText(NpcClass npc) { List <string> responses = npc.GetDialogueResponses(this.currentLineIndex); for (int i = 0; i < responses.Count; i++) { this.responseTexts[i].text = responses[i]; } yield return(null); }
// Controls the flow of the conversation public IEnumerator Converse(NpcClass npc) { Debug.Log("line index: " + this.currentLineIndex); // Npc Speaks yield return(this.StartCoroutine(this.SayLine(npc))); // Update responses yield return(this.StartCoroutine(this.UpdateResponseText(npc))); // Wait for player input & immediately reset bool for the next question yield return(new WaitUntil(() => this.isWaitingForResponse == false)); this.isWaitingForResponse = true; // Pick a random corerct answer int correctAnswer = Random.Range(0, npc.GetDialogueResponses(this.currentLineIndex).Count); // Update player phunk meter if chosen answer matches correct answer if (this.currentResponseIndex == correctAnswer) { this.gameManager.IncreasePlayerPhunk(GameManager.answerPoints); Debug.Log("Correct Answer"); } // Increase counter this.currentLineIndex++; // Call converse if there are more dialogue lines if (this.currentLineIndex < npc.GetDialogueCount()) { this.StartCoroutine(this.Converse(npc)); } else { this.EnableDialogueUI(false); } yield return(null); }