private void TestDialogueSystem() { foreach (NPC npc in npcs) { if (npc.canInteract()) { ContentManager content = gameRef.Content; Texture2D tooltipBackground = content.Load <Texture2D>(@"GUI\Inventory\Tooltip\background-v2"); Texture2D tooltipBorder = content.Load <Texture2D>(@"GUI\Inventory\Tooltip\border-v6"); SpriteFont font = content.Load <SpriteFont>(@"Fonts\ItemDataFont"); Rectangle screenRectangle = gameRef.ScreenRectangle; SimpleHUDWindow dialogueWindow = new SimpleHUDWindow(font); DialogueComponent dialogueComponent = new DialogueComponent(font, gameRef.Content, npc); dialogueComponent.RegisterCommand(Keys.Escape, CloseDialogueWindow, ClickState.RELEASED); dialogueComponent.RegisterCommand(Keys.E, CloseDialogueWindow, ClickState.RELEASED); dialogueWindow.Size = new Vector2(screenRectangle.Width * (2f / 3f), (screenRectangle.Height / 2f) - 100); dialogueWindow.Position = new Vector2( (screenRectangle.Width - dialogueWindow.Size.X) / 2f, screenRectangle.Height / 2f + (screenRectangle.Height / 2f - dialogueWindow.Size.Y) / 2f); dialogueWindow.Title = npc.Name; dialogueWindow.BorderTexture = tooltipBorder; dialogueWindow.Component = dialogueComponent; dialogueWindow.Show(); dialogueComponent.DialogueSelected += dialogueManager.OnSelected; hudManager.Put(Window.DIALOGUE, dialogueWindow); isPaused = true; break; } } }
public static DialogueComponent SetDialogue(this BaseCharacterControl mainSpeaker, DialogueStruct[][] dialogues, int[,] linkInfo) { DialogueComponent temp = mainSpeaker.SetDialogue(); temp.Dialogue = new DialogueGraph(dialogues, linkInfo); return(temp); }
void ShowOptions(DialogueComponent com) { this.ShowMessage(com.Dialogue); //Resetting options panel this.options.ForEach(x => x.gameObject.SetActive(false)); if (com is DialogueComposite) { DialogueComposite composite = (DialogueComposite)com; for (int i = 0; i < composite.NumberOfOptions; i++) { var temp = i; this.options[i].gameObject.SetActive(true); this.options[i].transform.GetChild(0).GetComponent <Text>().text = composite.Get(temp).Option; this.options[i].GetComponent <Button>().onClick.AddListener(() => { this.Display(composite, temp); }); } } else { Debug.Log("End LEAF NODE"); } }
public static DialogueComponent setDialogue(this BaseCharacterControl mainSpeaker, DialogueStruct[][] dialogues, int[,] linkInfo, bool auto, bool StandStill, DialogueComponentBase.DialogueStart startConv, DialogueComponentBase.DialogueRepetition repeat, float radius) { DialogueComponent temp = mainSpeaker.setDialogue(dialogues, linkInfo, auto, StandStill, startConv, repeat); temp.Radius = radius; return(temp); }
private void ClearAll() { ClearContainer(); _activeDialogueComponent = null; _closeAfterLinesShown = false; _itemsToDisplay.Clear(); _linesToDisplay.Clear(); }
public DialogueManager(DialogueComponent dialogueComponent) { m_dialogueComponent = dialogueComponent; m_dialogueBox = dialogueComponent.GetDialogueBox(); m_speaker = dialogueComponent.GetSpeaker(); m_dialogue = dialogueComponent.GetDialogue(); }
/// <summary> /// are you sure you want to construct your own DialogueManager? You may want to use /// SceneManager.GetInstance().GetDialogueManager() instead /// </summary> /// <param name="dialogueComponent">a dialogue component which houses the relevent UI elements</param> public DialogueManager(DialogueComponent dialogueComponent) { m_dialogueComponent = dialogueComponent; // assign references to all the relevant dialogue elements m_dialogueBox = dialogueComponent.GetDialogueBox(); m_speaker = dialogueComponent.GetSpeaker(); m_dialogue = dialogueComponent.GetDialogue(); }
// storeDialogueFromFile public static void storeDialogueFromFile(string source, string destination) { string line; string[] data; List <DialogueComponent> dList = new List <DialogueComponent>(); List <Choice> choices; int lineCount = 0; StreamReader reader = new StreamReader(File.OpenRead(source + ".csv")); // read to the end of the file line by line while (!reader.EndOfStream) { line = reader.ReadLine(); choices = new List <Choice>(); if (lineCount != 0) { data = line.Split(','); data[3] = data[3].Replace('%', ','); // init dialogue component DialogueComponent component = new DialogueComponent(int.Parse(data[0]), int.Parse(data[1]), data[2], data[3], getActionFromString(data[4])); // get choices, if any int next = 0; string name = ""; Constants.Action action = Constants.Action.NONE; for (int i = 5; i < data.Length; ++i) { if (i % 3 == 2) { name = data[i]; } else if (i % 3 == 0) { int.TryParse(data[i], out next); } else if (i % 3 == 1) { action = getActionFromString(data[i]); if (name != "") { choices.Add(new Choice(next, name, action)); } } } component.choiceWrapper = new ChoiceWrapper(choices); dList.Add(component); } ++lineCount; } reader.Close(); storeDialogue(new DialogueWrapper(dList), destination); }
public static DialogueComponent setDialogue(this BaseCharacterControl mainSpeaker, DialogueStruct[][] dialogues, int[,] linkInfo, bool auto, bool StandStill, DialogueComponentBase.DialogueStart startConv, DialogueComponentBase.DialogueRepetition repeat) { DialogueComponent temp = mainSpeaker.SetDialogue(dialogues, linkInfo); temp.Auto = auto; temp.Standingstill = StandStill; temp.StartConv = startConv; temp.Repeat = repeat; return(temp); }
public void StartDialogue() { if (!isActive) { isActive = true; nextDialogue = true; m_currentDialogueIndex = m_dialogueAsset.m_startIndex; currentActiveDialogue = this; OnDialogueStart(); } }
public void Show(DialogueComponent dialogue) { activateDialogueUI(); currentDialogue = dialogue; txtDialogue.text = currentDialogue.text; txtSpeaker.text = currentDialogue.speaker; if (player != null) { player.setPlayerCanMove(false); } }
public void remove(DialogueComponent dc) { if (dc is Condition) { conditions.Remove((Condition)dc); } else if (dc is Quote) { quotes.Remove((Quote)dc); } else if (dc is Action) { actions.Remove((Action)dc); } }
// Log private void AddToLog(DialogueComponent dc) { return; /* * // Exit if not adding anything to log * if (dc.type == DialogueComponentType.Animation) * { * // pass * return; * } * else if (dc.type == DialogueComponentType.CharacterChange) * { * // pass * return; * } * else if (dc.type == DialogueComponentType.MusicChange) * { * // pass * return; * } * else if (dc.type == DialogueComponentType.SFX) * { * // pass * return; * } * * GameObject newLogEntry = Instantiate(LogEntryPrefab); * var newLogText = newLogEntry.GetComponent<TextMeshProUGUI>(); * * // Assign text based on dc * if (dc.type == DialogueComponentType.Text) * { * newLogText.text = "<b>" + dc.speakerName + "</b><br>"; * newLogText.text += dc.textContent; * } * * newLogEntry.transform.SetParent(LogGrid.transform); * newLogEntry.transform.localScale = new Vector3(1, 1, 1); * //newLogEntry.transform.positio * newLogEntry.SetActive(true); */ }
public void ChangeDialogueComponent(string modifRef) { DialogueComponent DC = dialogues.Find(x => x.modificationName == modifRef); //Destroy(DC.characterToModify.GetComponent<PNJ>()); //PNJ pnjComponent = DC.newComponent; PNJ oldComponent = DC.characterToModify.GetComponent <PNJ>(); oldComponent.transitionQuote = DC.newComponent.transitionQuote; oldComponent.PNJName = DC.newComponent.PNJName; oldComponent.eventsActivationList = DC.newComponent.eventsActivationList; /*if(DC.newComponent.eventsActivationList.Count > 0) * { * for(int i = 0; i < DC.newComponent.eventsActivationList.Count; i++) * {oldComponent.eventsActivationList.Add(new PNJ.EventsTriggeredByStickers{DC.newComponent.eventsActivationList.})} * }*/ oldComponent.negativeQuote = DC.newComponent.negativeQuote; oldComponent.allDialogs = DC.newComponent.allDialogs; oldComponent.stickerRedirection = DC.newComponent.stickerRedirection; oldComponent.eventRedirection = DC.newComponent.eventRedirection; oldComponent.haveEvent = DC.newComponent.haveEvent; oldComponent.stickerAlreadyGivenList = DC.newComponent.stickerAlreadyGivenList; oldComponent.stickersAlreadyGiven = DC.newComponent.stickersAlreadyGiven; }
void InitializeDialogues() { root = new DialogueComposite("", string.Format("Hi there, {0}", this.name)); //;Level 1 levelTwo = new DialogueComposite("Level 2", "Reply 2"); //;Level 2 levelThree = new DialogueComposite("Level 3", "Reply 3"); //;Level 3 levelFour = new DialogueComposite("Level 4", "Reply 4"); //;Level 4 levelFive = new DialogueComposite("Level 5", "Reply 5"); //;Level 2 root.AddOption(levelTwo); root.AddOption(new Dialogue("L1_PO_A", "L1_Reply A")); root.AddOption(new Dialogue("L1_PO_B", "L1_Reply B")); levelTwo.AddOption(levelThree); levelTwo.AddOption(new Dialogue("L2_PO_A", "L2_Reply A")); levelTwo.AddOption(new Dialogue("L2_PO_B", "L2_Reply B")); levelThree.AddOption(new Dialogue("L3_PO_A", "L3_Reply A")); levelThree.AddOption(levelFour); levelThree.AddOption(new Dialogue("L3_PO_B", "L3_Reply B")); levelFour.AddOption(new Dialogue("L4_PO_A", "L4_Reply A")); levelFour.AddOption(levelFive); levelFour.AddOption(new Dialogue("L4_PO_B", "L4_Reply B")); levelFour.AddOption(new Dialogue("L4_PO_C", "L4_Reply C")); levelFive.AddOption(new Dialogue("L5_PO_A", "L5_Reply A")); levelFive.AddOption(new Dialogue("L5_PO_B", "L5_Reply B")); levelFive.AddOption(new Dialogue("L5_PO_C", "L5_Reply C")); levelFive.AddOption(new Dialogue("L5_PO_D", "L5_Reply D")); levelFive.AddOption(new Dialogue("L5_PO_E", "L5_Reply E")); ShowOptions(root); }
void Awake() { _dc = GetComponent <DialogueComponent>(); nextSetBtn.onClick.AddListener(_dc.GoToNextDialogue); }
public void StopDialogue() { isActive = false; currentActiveDialogue = null; OnDialogueComplete(); }
public virtual void AddOption(DialogueComponent com) { }
public static void DispatchDialogueStartedEvent(DialogueComponent dialogueComponent) { Instance.EmitSignal(nameof(EventDialogueStarted), DIALOGUE_STARTED, dialogueComponent); }
public override void AddOption(DialogueComponent com) { this.replies.Add(com); }
public virtual void RemoveOption(DialogueComponent com) { }
public override void RemoveOption(DialogueComponent com) { this.replies.Remove(com); }
private void UpdatePassiveDialogue() { DialogueData dialogue; m_dialogueAsset.m_dialogueData.TryGetValue(m_currentDialogueIndex, out dialogue); CharacterComponent characterComp; m_dialogueAsset.m_characterData.TryGetValue(dialogue.characterName, out characterComp); if (nextDialogue) { if (!dialogue.m_isStartNode && !dialogue.m_isEventNode) { Vector3 dialoguePosition = characterComp.GetCurrentOffset(); // do all the actions for the current dialogue m_textDisplay.DisplayPassiveBubble(true, characterComp.GetCurrentBubblePos()); m_textDisplay.Display(dialogue.dialogueText, dialoguePosition); //character comp related actions characterComp.OnCharacterTalk(dialogue.GetDialogueTextWithoutTags()); SetAllCharacterEmotions(dialogue); nextDialogue = false; } else { if (dialogue.isConditionalBranching) { m_currentDialogueIndex = CheckDialogueConditions(dialogue); nextDialogue = true; } else if (dialogue.m_nextDialogueData.Count == 1) { m_currentDialogueIndex = dialogue.m_nextDialogueData[0]; nextDialogue = true; } else if (dialogue.m_nextDialogueData.Count > 1) { // display all branching options DisplayDialogueOptions(dialogue.m_nextDialogueData); nextDialogue = false; } else if (dialogue.m_nextDialogueData.Count == 0) { isActive = false; currentActiveDialogue = null; m_textDisplay.DisplayPassiveBubble(false, new Vector3(0, 0, 0)); OnDialogueComplete(); } } UpdateInventory(dialogue); UpdateQuests(dialogue); for (int i = 0; i < dialogue.eventObjects.Count; ++i) { dialogue.eventObjects[i].SendMessage(dialogue.eventFunctions[i]); } } bool isNextDialogueButtonPressed = Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Mouse0); if (isNextDialogueButtonPressed && !m_textDisplay.iSDone()) { Vector3 dialoguePosition = characterComp.GetCurrentOffset(); m_textDisplay.StopTypeWriterEffect(); m_textDisplay.ClearDisplay(); m_textDisplay.AddToDisplayImmediate(dialogue.dialogueText, dialoguePosition); return; } if (isNextDialogueButtonPressed && m_textDisplay.iSDone()) { m_textDisplay.ClearDisplay(); // next dialogue is not branching if (dialogue.m_nextDialogueData.Count == 1) { m_currentDialogueIndex = dialogue.m_nextDialogueData[0]; hasPlayerOptions = false; nextDialogue = true; } // next dialogue is branching else if (dialogue.m_nextDialogueData.Count > 1) { if (dialogue.isConditionalBranching) { m_currentDialogueIndex = CheckDialogueConditions(dialogue); nextDialogue = true; } } // dialogue is now complete if (dialogue.m_nextDialogueData.Count == 0) { isActive = false; currentActiveDialogue = null; m_textDisplay.DisplayPassiveBubble(false, new Vector3(0, 0, 0)); OnDialogueComplete(); } } }
private void OnDialogueStarted(string eventGuid, DialogueComponent dialogueComponent) { Open(); _activeDialogueComponent = dialogueComponent; InitializeContent(); }
private void UpdateActiveDialogue() { DialogueData dialogue; m_dialogueAsset.m_dialogueData.TryGetValue(m_currentDialogueIndex, out dialogue); CharacterComponent characterComp; m_dialogueAsset.m_characterData.TryGetValue(dialogue.characterName, out characterComp); if (nextDialogue) { if (!dialogue.m_isStartNode && !dialogue.m_isBranching && !dialogue.m_isEventNode) { m_textDisplay.DisplayDialogueHeader(dialogue.characterName, characterComp.characterIcon); // do all the actions for the current dialogue m_textDisplay.StopDisplayingOptions(); m_textDisplay.DisplayActiveOptionBubble(false, 0); m_textDisplay.DisplayActiveBubble(true); m_textDisplay.Display(dialogue.dialogueText); //character comp related actions characterComp.OnCharacterTalk(dialogue.GetDialogueTextWithoutTags()); SetAllCharacterEmotions(dialogue); nextDialogue = false; } else { if (dialogue.isConditionalBranching) { m_currentDialogueIndex = CheckDialogueConditions(dialogue); nextDialogue = true; } else if (dialogue.m_nextDialogueData.Count == 1) { m_currentDialogueIndex = dialogue.m_nextDialogueData[0]; nextDialogue = true; } else if (dialogue.m_nextDialogueData.Count > 1) { // display all branching options DisplayDialogueOptions(dialogue.m_nextDialogueData); nextDialogue = false; } else if (dialogue.m_nextDialogueData.Count == 0) { isActive = false; currentActiveDialogue = null; m_textDisplay.DisplayActiveBubble(false); OnDialogueComplete(); } } UpdateInventory(dialogue); UpdateQuests(dialogue); // triggering dialogue game events for (int i = 0; i < dialogue.eventObjects.Count; ++i) { dialogue.eventObjects[i].SendMessage(dialogue.eventFunctions[i]); } } bool isNextDialogueButtonPressed = Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Mouse0) || Input.GetKeyDown(KeyCode.E); if (isNextDialogueButtonPressed && !m_textDisplay.iSDone()) { m_textDisplay.StopTypeWriterEffect(); m_textDisplay.ClearDisplay(); m_textDisplay.DisplayDialogueHeader(dialogue.characterName, characterComp.characterIcon); m_textDisplay.AddToDisplayImmediate(dialogue.dialogueText); return; } if (isNextDialogueButtonPressed && m_textDisplay.iSDone()) { m_textDisplay.ClearDisplay(); // next dialogue is not branching if (dialogue.m_nextDialogueData.Count == 1) { m_currentDialogueIndex = dialogue.m_nextDialogueData[0]; hasPlayerOptions = false; nextDialogue = true; } // next dialogue is branching else if (dialogue.m_nextDialogueData.Count > 1) { if (!dialogue.isConditionalBranching) { // display all branching options DisplayDialogueOptions(dialogue.m_nextDialogueData); } else { m_currentDialogueIndex = CheckDialogueConditions(dialogue); nextDialogue = true; } } // branching option chosen if (optionChosen == true) { m_currentDialogueIndex = dialogue.m_nextDialogueData[playerSelectedOption]; hasPlayerOptions = false; nextDialogue = true; m_textDisplay.ClearDisplay(); optionChosen = false; playerSelectedOption = 0; } // dialogue is now complete if (dialogue.m_nextDialogueData.Count == 0) { isActive = false; currentActiveDialogue = null; m_textDisplay.DisplayActiveBubble(false); OnDialogueComplete(); } } // selecting player option else if (hasPlayerOptions) { float verticalInput = Input.GetAxisRaw("Vertical"); if (verticalInput != 0 && canChangeOption) { canChangeOption = false; StartCoroutine(ChangePlayerOption(dialogue.m_nextDialogueData.Count, verticalInput)); DisplayDialogueOptions(dialogue.m_nextDialogueData); } optionChosen = true; } }
private void DisplayNextComponent() { if (dialogueComponentQueue.Count == 0) { EndDialogue(); return; } // Handle the component based on type DialogueComponent dialogueComponent = dialogueComponentQueue.Dequeue(); // Add to history log AddToLog(dialogueComponent); if (dialogueComponent.type == DialogueComponentType.Text) { DeactivateNameplates(); if (dialogueComponent.namePlateAlignment == DialogueComponent.NamePlateAlignment.Left) { nameplateLeft.SetActive(true); TrySetNameplateText(nameplateLeft, dialogueComponent.speakerName); } else if (dialogueComponent.namePlateAlignment == DialogueComponent.NamePlateAlignment.Right) { nameplateRight.SetActive(true); TrySetNameplateText(nameplateRight, dialogueComponent.speakerName); } else if (dialogueComponent.namePlateAlignment == DialogueComponent.NamePlateAlignment.Center) { nameplateCenter.SetActive(true); TrySetNameplateText(nameplateCenter, dialogueComponent.speakerName); } else { // pass } if (typingCoroutine != null) { StopCoroutine(typingCoroutine); } typingCoroutine = StartCoroutine(TypeSentence(dialogueComponent.textContent)); } else if (dialogueComponent.type == DialogueComponentType.Image) { if (animCoroutine != null) { StopCoroutine(animCoroutine); } if (dialogueComponent.imageNumber >= images.Length) { // pass } else { animCoroutine = StartCoroutine(TransitionImage(images[dialogueComponent.imageNumber], dialogueComponent.image)); } DisplayNextComponent(); } /* * else if (dialogueComponent.type == DialogueComponentType.Animation) * { * if (dialogueComponent.animationName == "BlackPanelDisplay") * { * animPanelTitleText.text = dialogueComponent.speakerName; * animPanelSubText.text = dialogueComponent.textContent; * animPanelAnimator.SetTrigger("BlackPanelDisplay"); * } * DisplayNextComponent(); * } */ else if (dialogueComponent.type == DialogueComponentType.SFX) { sfxPlayer.PlayOneShot(dialogueComponent.soundEffect); DisplayNextComponent(); } else if (dialogueComponent.type == DialogueComponentType.Music) { if (dialogueComponent.song == null) { musicPlayer.Stop(); } else { musicPlayer.clip = dialogueComponent.song; musicPlayer.Play(); } DisplayNextComponent(); } else { Debug.Log("Given dialogueComponent without type, this is INVALID!"); DisplayNextComponent(); } }
void Display(DialogueComponent cmp, int inde) { ShowOptions(cmp.Get(inde)); }
public Node(DialogueComponent component) : base() { this.data = component; Click += (sender, e) => Managers.Control.select(this); }