public void StartCaptions(ConversationAction action, int dialogueIndex) { if (dialogueIndex >= action.Conversations.Count) { for (int i = 0; i < action.InvolvedActors.Count; i++) { Actor actor = GameManager.Instance.Actors[action.InvolvedActors[i]].GetComponent <Actor>(); if (actor.CurAction is ConversationAction) { actor.ExecuteAction(actor.ActionIndex + 1); } else { actor.ResumeAction(); } } return; } AIDialogue dialogue = action.Conversations[dialogueIndex]; StartCoroutine(DelayedFunction(HideIndicator, dialogue.Delay - 0.1f)); int actorID = action.Conversations[dialogueIndex].SpeakerGOIndex; currentSpeaker = actorID; conversationIndex = dialogueIndex; currentAction = action; GameManager.Instance.Actors[actorID].GetComponent <Actor>().CaptionIndicator.SetActive(true); CaptionsPanel.SetActive(true); captionsText.text = dialogue.SpeakerText + ": " + dialogue.Dialogue; captionsText.maxVisibleCharacters = 0; LeanTween.value(captionsText.gameObject, (float x) => captionsText.maxVisibleCharacters = (int)x, 0, captionsText.text.Length, 1); StartCoroutine(DelayedFunction(RunNextCaption, dialogue.Delay)); GetComponentInChildren <CaptionsText>().Target = GameManager.Instance.Actors[actorID].transform; currentAction = action; }
public void SetOptions(List <Answer> answers, AIDialogue aiDialogue) { if (answers.Count > 2) // if has 3 answers { optionScriptBtn1.gameObject.SetActive(true); // show first button optionScriptBtn2.gameObject.SetActive(true); // show second button optionScriptBtn3.gameObject.SetActive(true); // show third button option1.text = answers[0].option; // FIRST button with FIRST answer optionScriptBtn1.reference = answers[0].reference; optionScriptBtn1.AIDialogue = aiDialogue; option2.text = answers[1].option; // FIRST answer with SECOND button optionScriptBtn2.reference = answers[1].reference; optionScriptBtn2.AIDialogue = aiDialogue; option3.text = answers[2].option; // THIRD answer with THIRD button optionScriptBtn3.reference = answers[2].reference; optionScriptBtn3.AIDialogue = aiDialogue; } else if (answers.Count > 0) // if has 1 answer { optionScriptBtn1.gameObject.SetActive(false); // hide first button optionScriptBtn3.gameObject.SetActive(true); // show second button optionScriptBtn3.gameObject.SetActive(false); // hide third button option2.text = answers[0].option; // SECOND button with FIRST answer optionScriptBtn2.reference = answers[0].reference; optionScriptBtn2.AIDialogue = aiDialogue; } else // if has no answers { CloseOptions(); // close the options } }
public void StartDialogue(List <Dialogue> dialogue, string name, int reference, AIDialogue aiDialogue) // Starts the Dialogue (Recieves the list of dialogues, name of character, reference (default 1), NPC AIDialogue Script) { playerDialogueManager.enabled = true; animator.SetBool("isOpen", true); // Opening Text in Game nameText.text = name; // Setting the NPC name sentences.Clear(); // Clearing all the setences continueText.text = "Next..."; // Setting the Button for Next (Default) Can be modified by editor if needed _dialogue = dialogue; // Setting the global dialogue _aiDialogue = aiDialogue; for (int i = 0; i < _dialogue.Count; i++) // Looping all the Dialogues { if (_dialogue[i].reference == reference) // Checking reference { _reference = i; // Setting reference } } foreach (string sentence in _dialogue[_reference].sentences) // Looping every sentence related to the reference { sentences.Enqueue(sentence); // Enqueuing the sentences } DisplayNextSentence(); // Displaying the next sentence }