private void Awake() { if (_instance != null && _instance != this) Destroy(this.gameObject); else _instance = this; }
IEnumerator Running() { //VariableManager.Inject(ref dialogue); string[] parts = dialogue.Split('[', ']'); for (int i = 0; i < parts.Length; i++) { bool isOdd = i % 2 != 0; if (isOdd) { DialogueEvents.HandleEvent(parts[i], this); allCurrentlyExecutedEvents.Add(parts[i]); i++; } string targDialogue = parts[i]; VariableManager.Inject(ref targDialogue); //Debug.Log("SAY THIS-" + targDialogue); DialogueSystem.instance.Say(targDialogue, line.speaker, i > 0 ? true : pretext != ""); architect = DialogueSystem.instance.TextArchitect; while (architect.isConstructing) { yield return(new WaitForEndOfFrame()); } } running = null; }
public void HaveConversation() { //Debug.Log("HaveConversation called in Dialogue.cs"); if (!conversationOver) { Initialized = true; /*Events will return null if 1. nobody is listening to it * 2.somebody is listening but not doing anything in the method */ DialogueEvents.FireAnEvent_OnDialogueStart(this); //disable user input..were having a GOD DAMN conversation! Global.USER_INPUT_ENABLED = false; Global.HAVING_A_CONVERSATION = true; textDisplay.text = ""; textDisplay.enabled = true; //must be delayed until player is in a fixed position StartCoroutine(FaceMyFriend()); StartCoroutine(Talk()); } else { Debug.Log("Conversation is over, nothing to say"); } }
public int ReturnEventIndex(DialogueEvents myDE) { for (int i = 0; i < transform.childCount; i++) { if (myEventsNames[i] == myDE.gameObject.name) { Debug.Log("the index is " + i); return(i); } } return(9999); }
IEnumerator Running() { allCurrentlyExecutedEvents.Clear(); //take care of any tags that must be injected into the dialogue before we worry about events. TagManager.Inject(ref dialogue); //split the dialogue by the event characters. string[] parts = dialogue.Split('[', ']'); for (int i = 0; i < parts.Length; i++) { //events will always be odd indexed. Execute an event. bool isOdd = i % 2 != 0; if (isOdd) { DialogueEvents.HandleEvent(parts[i], this); allCurrentlyExecutedEvents.Add(parts[i]); i++; } string targDialogue = parts[i]; if (line.speaker != "narrator" && !line.speaker.Contains("*")) { print(line.speaker); Character character = CharacterManager.instance.GetCharacter(line.speaker); //This is a valid character that can show up on the screen. Get the character and make them speak. //if (character != null) character.Say(targDialogue, i > 0 ? true : pretext != ""); //This is a character that has no images to display. Only show the name and the dialogue. //else //DialogueSystem.instance.Say(targDialogue, line.speaker, i > 0 ? true : pretext != ""); does not work yet } else { DialogueSystem.instance.Say(targDialogue, line.speaker, i > 0 ? true : pretext != ""); } //yield while the dialogue system's architect is constructing the dialogue. architect = DialogueSystem.instance.currentArchitect; //TODO while (architect.isConstructing) { yield return(new WaitForEndOfFrame()); } } running = null; }
public void ForceFinish() { if (running != null) { NovelController.instance.StopCoroutine(running); } running = null; if (architect != null) { architect.ForceFinish(); //time to complete the entire dialogue string since an interrupted segment with events will only autocomplete to the next event. if (pretext == "") { line.lastSegmentsWholeDialogue = ""; } //execute all actions that have not been made yet. string[] parts = dialogue.Split('[', ']'); for (int i = 0; i < parts.Length; i++) { bool isOdd = i % 2 != 0; if (isOdd) { string e = parts[i]; if (allCurrentlyExecutedEvents.Contains(e)) { allCurrentlyExecutedEvents.Remove(e); } else { DialogueEvents.HandleEvent(e, this); } i++; } //append only the dialogue to the whole dialogue and make the architect show it. line.lastSegmentsWholeDialogue += parts[i]; } //show the whole dialogue on the architect. architect.ShowText(line.lastSegmentsWholeDialogue); } }
void NextSentence() { isTyping = true; if (index < sentence.Length - 1) { index++; textDisplay.text = ""; StartCoroutine(Talk()); isTyping = false; } else//conversation complete { Global.HAVING_A_CONVERSATION = false; //my_rigidBody.isKinematic = false; Initialized = false; conversationOver = true; DialogueEvents.FireAnEvent_OnDialogueEnd(this); //Debug.Log(this + " fired an OnDialogueEnd"); GetComponentInParent <QuestGiver>().EnableAndAssignMyQuest(assignsQuestWhenOver); //Debug.Log("Conversation complete, achievement unlocked");//TODO achievement system popup PlayerController player = ObjectFinder.PlayerController; //Debug.Log("dialogue fetched " + player); player.alreadySpeaking = false; Global.USER_INPUT_ENABLED = true; player.transform.rotation = Quaternion.identity; Rigidbody playersRigidBody = player.GetComponent <Rigidbody>(); playersRigidBody.constraints = RigidbodyConstraints.None; //unfreeze playersRigidBody.constraints = RigidbodyConstraints.FreezeRotation; //refreeze to ground Invoke("ClearText", 2f); textDisplay.enabled = false; FacingFriend = false; //reset secret dialogue flag so they can load another conversation GetComponentInParent <QuestGiver>().hasDisocveredSecretDialogue = false; if (dialogueID == "Ip-0") { NPC_AI ip_AI = GetComponentInParent <NPC_AI>(); ip_AI.GoHome(); } } }
public void ForceFinish() { if (isRunning) { DialogueController.instance.StopCoroutine(running); } running = null; if (architect != null) { architect.ForceFinish(); if (pretext == "") { line.lastSegmentsWholeDialogue = ""; } string[] parts = dialogue.Split('[', ']'); for (int i = 0; i < parts.Length; i++) { bool isOdd = i % 2 != 0; if (isOdd) { string actions = parts[i]; if (allCurrentlyExecutedEvents.Contains(actions)) { allCurrentlyExecutedEvents.Remove(actions); } else { DialogueEvents.HandleEvent(actions, this); } i++; } line.lastSegmentsWholeDialogue += parts[i]; } architect.ShowText(line.lastSegmentsWholeDialogue); } }
IEnumerator Running() { allCurrentlyExecutedEvents.Clear(); TagManager.Inject(ref dialogue); string[] parts = dialogue.Split('[', ']'); for (int i = 0; i < parts.Length; i++) { bool isOdd = i % 2 != 0; if (isOdd) { DialogueEvents.HandleEvents(parts[i], this); allCurrentlyExecutedEvents.Add(parts[i]); i++; } string targetDialogue = parts[i]; print("dialog = " + parts[i]); if (line.speaker != "narator" && line.speaker != "MC") { Character character = CharacterManager.instance.GetCharacter(line.speaker); character.say(targetDialogue, i > 0 ? true : pretext != ""); } else if (line.speaker == "MC") { DIalogueSystem.instance.Say(targetDialogue, "Adovandria", i > 0 ? true : pretext != ""); } else { DIalogueSystem.instance.Say(targetDialogue, line.speaker, i > 0 ? true : pretext != ""); } architect = DIalogueSystem.instance.currentArchitect; while (architect.isConstructing) { yield return(new WaitForEndOfFrame()); } } running = null; }
void Awake() { _dialogueEvents = this; }