private void PrintDialogueToString() { // print dialogue nameTxtBox.text = nextMessage.name; dialogueTextBox.text = nextMessage.dialogue; // print choices if there are any and stop advancement if (nextMessage.choices != null && nextMessage.choices.Count > 0) { // enable choices and top advance choicesOpen = true; for (int i = 0; i < nextMessage.choices.Count; i++) { choiceButtons[i].gameObject.SetActive(true); choiceButtonsText[i].text = nextMessage.choices[i].optionText; } } else if (nextMessage.next != null) { // advance cursor. choicesOpen = false; nextMessage = nextMessage.next; } else if (nextMessage.endAction != null) { nextMessage.endAction(); } else { //you fucked up if you are here. } }
public void AddMessage(DialogueMessage text) { if (messages.Count == 0) messages.Add(new DialogueMessage("", 0f, 0)); messages.Add(text); }
/// <summary> /// Plays the next dialogue message from the queue /// </summary> public void ContinueDialogue() { if (dialogueMessages.Count > 0) { ResetUI(); dialoguePanel.SetActive(true); DialogueMessage dialogue = dialogueMessages.Dequeue(); characterNameBox.text = dialogue.character; // Load the buttons if it was the last dialogue message if (dialogueMessages.Count == 0) { OnPrintCompleted += CreateButtons; } nextButton.gameObject.SetActive(dialogueMessages.Count > 0 || dialogueChoices.Count == 0); // Only one print coroutine at a time StopAllCoroutines(); StartCoroutine(PrintMessage(dialogue.message)); } else if (dialogueChoices.Count == 0) { OnDialogueEnd?.Invoke(); } }
private void SaveGameplayDialogues() { Dialogue dialogue = new Dialogue(dialogues[currDialogueIdx].id, dialogues[currDialogueIdx].name); DialogueMessage[] messages = new DialogueMessage[nodes.Count]; for (int i = 0; i < messages.Length; i++) { messages[i] = new DialogueMessage(nodes[i].nodeID, nodes[i].actorID, nodes[i].text); } // Making Message Hierarchy. for (int i = 0; i < connections.Count; i++) { int parentMsgID = connections[i].outPoint.ownerNode.nodeID; int childMsgID = connections[i].inPoint.ownerNode.nodeID; DialogueMessage parentMsg = Dialogue.GetMessageByID(messages, parentMsgID); parentMsg.childMsgIDs.Add(childMsgID); } dialogue.rootMessageIDs = new int[1]; dialogue.rootMessageIDs[0] = 0; dialogue.messages = messages; string filePath = DialogueManager.GetDialogueFilePath(dialogue.GetID()); BinaryIO.WriteToBinaryFile(filePath, dialogue); }
public void Init() { _theUi = new TheUI("throneroom", "panickedadvisor"); message = new DialogueMessage( "This is a really really really really really really really really really really really really really really long line.", _theUi, "panickedadvisor", "none"); }
public void ClickOption(int optionNumber) { // change dialogue choicesOpen = false; nextMessage = nextMessage.choices[optionNumber].next; foreach (Button button in choiceButtons) { button.gameObject.SetActive(false); } PrintDialogueToString(); }
private void OnExplosionsEnd() { DialogueMessage msg = new DialogueMessage(); msg.Character = "Scientist"; msg.Message = "Carefully now, he's a hero."; msg.Time = 3.0f; diagBox.Message(msg); Destroy(player.gameObject); SceneManager.LoadScene("Scenes/MainMenu"); }
private void confirmAnswer(DialogueMessage selectedAnswer) { if (OnAnswerConfirmed != null) { OnAnswerConfirmed.Invoke(selectedAnswer); choosingMode = false; foreach (var item in listOfAnswers) { Destroy(item); } listOfAnswers.Clear(); } }
public void Message(DialogueMessage mes) { messages[firstEmpty] = mes; if (firstEmpty == currentMessage) { messageBox.SetActive(true); messageTime = -1; characterProfile.GetComponent <RawImage>().uvRect = getCrop(messages[currentMessage].Character); //Updates character crop characterProfile.GetComponent <RawImage>().texture = getTexture(messages[currentMessage].Character); //Updates character image } firstEmpty++; if (firstEmpty >= 100) { firstEmpty = 0; } }
void Start() { AS = GetComponent <AudioSource>(); // this reads easier if you start from the bottom and go up. // If you want to do this somewhere else copy and paste the script and redo this part I'm not making it modular. DialogueMessage failMsg2 = new DialogueMessage() { name = "Neighborhood Man", dialogue = "fook off", endAction = SpeechCheckFail }; DialogueMessage failMsg = new DialogueMessage() { name = "Neighborhood Man", dialogue = "fook off", next = failMsg2 }; DialogueMessage passMsg2 = new DialogueMessage() { name = "Neighborhood Man", dialogue = "I'll take 50 cans.", endAction = SpeechCheckPass }; DialogueMessage passMsg = new DialogueMessage() { name = "Neighborhood Man", dialogue = "I'll take 50 cans.", next = passMsg2 }; DialogueMessage msg6_2 = new DialogueMessage() { name = "Neighborhood Man", dialogue = "Oh that makes sense.", next = passMsg }; DialogueMessage msg6_1 = new DialogueMessage() { name = "Skipper", dialogue = "It's very good for dipping and complements starches as a side.", next = msg6_2 }; DialogueMessage msg5_4 = new DialogueMessage() { name = "Skipper", dialogue = "I'm going to force feed you it.", next = failMsg }; DialogueMessage msg5_3 = new DialogueMessage() { name = "Neighborhood Man", dialogue = "I'm not too sure about this.", next = msg5_4 }; DialogueMessage msg5_2 = new DialogueMessage() { name = "Neighborhood Man", dialogue = "*sips soup*", next = msg5_3 }; DialogueMessage msg5_1 = new DialogueMessage() { name = "Skipper", dialogue = "Here, give it a taste, it will change your mind.", next = msg5_2 }; DialogueChoice ch2_2 = new DialogueChoice() { optionText = "Explain yourself", next = msg6_1 }; DialogueChoice ch2_1 = new DialogueChoice() { optionText = "Give a sample", next = msg5_1 }; DialogueMessage msg4 = new DialogueMessage() { name = "Neighborhood Man", dialogue = "That sounds disgusting." }; msg4.choices.Add(ch2_1); msg4.choices.Add(ch2_2); DialogueMessage msg3_1 = new DialogueMessage() { name = "Skipper", dialogue = "I have a new flavor of soup here. It's called spicy nacho cheese.", next = msg4 }; DialogueMessage msg2_1 = new DialogueMessage() { name = "Skipper", dialogue = "How I shove this soup can up your ass.", next = failMsg }; DialogueChoice ch1_2 = new DialogueChoice() { optionText = "Be gentle", next = msg3_1 }; DialogueChoice ch1_1 = new DialogueChoice() { optionText = "Be aggressive", next = msg2_1 }; DialogueMessage msg1 = new DialogueMessage() { name = "Neighborhood Man", dialogue = "What do you mean? Are you selling me something?" }; msg1.choices.Add(ch1_1); msg1.choices.Add(ch1_2); topMessage = new DialogueMessage() { name = "Skipper", dialogue = "do you have time to listen to soup?", next = msg1 }; nextMessage = topMessage; wc = FindObjectOfType <WinController>(); nameBox.SetActive(false); nameTxtBox.gameObject.SetActive(false); dialogueBox.SetActive(false); dialogueTextBox.gameObject.SetActive(false); foreach (Button button in choiceButtons) { button.gameObject.SetActive(false); } }
public void showText(DialogueMessage inp) { if (message_count - start < MAX_MSG) { messages[Mathf.FloorToInt(message_count % MAX_MSG)] = inp; message_count++; } }
private void DisplayText(DialogueMessage inp) { if (inp.audio != null) { print("playing"); if (this.GetComponent<AudioSource>().clip != inp.audio || !this.GetComponent<AudioSource>().isPlaying) { this.GetComponent<AudioSource>().clip = inp.audio; this.GetComponent<AudioSource>().Play(); } } else if (inp.isPlayer) { print("playing"); if (this.GetComponent<AudioSource>().clip != p.voice || !this.GetComponent<AudioSource>().isPlaying) { this.GetComponent<AudioSource>().clip = p.voice; this.GetComponent<AudioSource>().Play(); } } else { print("did not play"); this.GetComponent<AudioSource>().Stop(); } if(inp.isPlayer) { ((Image)this.GetComponent<Transform>().FindChild("Portrait").GetComponent<Image>()).enabled = false; } else { ((Image)this.GetComponent<Transform>().FindChild("Portrait").GetComponent<Image>()).enabled = true; } if(inp.isConvo == false) { print("not a convo"); this.GetComponentInChildren<Text>().text = inp.message; ((Image)this.GetComponent<Transform>().FindChild("Portrait").GetComponent<Image>()).sprite = inp.picLoc; } else { print("is a convo"); p.isConvoMode = true; this.GetComponentInChildren<Text>().text = inp.message; ((Image)this.GetComponent<Transform>().FindChild("Portrait").GetComponent<Image>()).sprite = inp.picLoc; this.GetComponent<Transform>().FindChild("Option 1").gameObject.SetActive(true); this.GetComponent<Transform>().FindChild("Cursor 1").gameObject.SetActive(true); this.GetComponent<Transform>().FindChild("Option 2").gameObject.SetActive(true); p.setConvoMode(true, this.GetComponent<Transform>().FindChild("Cursor 1").gameObject, this.GetComponent<Transform>().FindChild("Cursor 2").gameObject); } }
public void HandleNextMessage() { bool allowContinue = true; if (msgIndex > 0) { DialogueMessage previousDm = messages[msgIndex - 1]; if (!previousDm.WasClosed && previousDm.LastMsg) { allowContinue = false; messages[msgIndex - 1].WasClosed = true; if (previousDm.MsgType == "Game") { Destroy(gWindowDialogue); Destroy(gTextDialogue); if (previousDm.AllowMovingAfter) { GameManager.Instance.allowMoving = true; } } if (previousDm.MsgType == "Player") { Destroy(pWindowDialogue); Destroy(pTextDialogue); if (previousDm.AllowMovingAfter) { GameManager.Instance.allowMoving = true; } } if (previousDm.MsgType == "Boss") { Destroy(bWindowDialogue); Destroy(bTextDialogue); if (previousDm.AllowMovingAfter) { GameManager.Instance.allowMoving = true; } } if (previousDm.MsgType == "FinalBoss") { Destroy(fWindowDialogue); Destroy(fTextDialogue); if (previousDm.AllowMovingAfter) { GameManager.Instance.allowMoving = true; } } } } if (allowContinue && msgIndex >= 0 && (msgIndex + 1) <= messages.Count) { DialogueMessage dm = messages[msgIndex]; string message = dm.Msg; if (dm.MsgType == "Game") { if (dm.FirstMsg) { gWindowDialogue = Instantiate(gameDialogWindow); gTextDialogue = Instantiate(gameDialogText); Renderer r = gTextDialogue.GetComponent <Renderer>(); r.sortingLayerName = "PlayerLayer"; gTextMesh = gTextDialogue.GetComponent <TextMesh>(); gTextMesh.text = dm.Msg; } else { gTextMesh.text = dm.Msg; } } if (dm.MsgType == "Player") { if (dm.FirstMsg) { print("1ª mensagem do player"); pWindowDialogue = Instantiate(playerDialogWindow); pTextDialogue = Instantiate(playerDialogText); Renderer r = pTextDialogue.GetComponent <Renderer>(); r.sortingLayerName = "PlayerLayer"; pTextMesh = pTextDialogue.GetComponent <TextMesh>(); pTextMesh.text = dm.Msg; } else { pTextMesh.text = dm.Msg; } } if (dm.MsgType == "Boss") { if (dm.FirstMsg) { bWindowDialogue = Instantiate(bossDialogWindow); bTextDialogue = Instantiate(bossDialogText); Renderer r = bTextDialogue.GetComponent <Renderer>(); r.sortingLayerName = "PlayerLayer"; bTextMesh = bTextDialogue.GetComponent <TextMesh>(); bTextMesh.text = dm.Msg; } else { bTextMesh.text = dm.Msg; } } if (dm.MsgType == "FinalBoss") { if (dm.FirstMsg) { fWindowDialogue = Instantiate(finalBossDialogWindow); fTextDialogue = Instantiate(finalBossDialogText); Renderer r = fTextDialogue.GetComponent <Renderer>(); r.sortingLayerName = "PlayerLayer"; fTextMesh = fTextDialogue.GetComponent <TextMesh>(); fTextMesh.text = dm.Msg; } else { fTextMesh.text = dm.Msg; } } msgIndex++; } }