Temp() { topic = new List<DialogueNode>(); topic.Add(new DialogueLine(0, "Hello")); topic.Add(new DialogueLine(1, "Mornin'")); topic.Add(new DialogueLine(0, "Who stole the cookie from the cookie jar?")); topic.Add(new DialogueLine(1, "You stole the cookie from the cookie jar.")); // id = 3 topic.Add(new DialogueLine(0, "Who me?")); topic.Add(new DialogueLine(1, "Yes, you!")); topic.Add(new DialogueLine(0, "Couldn't be!")); topic.Add(new DialogueLine(1, "Then who?")); DialogueChoice dc = new DialogueChoice(); Choice c = new Choice(); c.SetText("No idea."); c.AddOutcome(new OutcomeJump(3)); dc.AddChoice(c); c = new Choice(); c.AddOutcome(new OutcomeMood(0, -10)); c.SetText("I lied, it was me actually."); // Choices CAN have no outcome, dialogue continues from next line dc.AddChoice(c); c = new Choice(); c.AddOutcome(new OutcomeEnd()); c.SetText("*Run Away*"); dc.AddChoice(c); topic.Add(dc); topic.Add(new DialogueLine(1, "As expected, I'll be a master detective in no time.")); topic.Add(new DialogueLine(0, "A master without cookies that is.")); }
public DialogueLine(Sprite portrait = null, string text = null, float textSpeed = 0.001f, string name = "???", DialogueChoice choice = null) { Portrait = portrait; Text = text; TextSpeed = (textSpeed == default(float) ? DEFAULT_SPEED : textSpeed); Name = name ?? DEFAULT_NAME; Choice = choice; }
public void MyTestInitialize() { _mgr = new DialogueManager(); _dlg = _mgr.AddDialogue(_dlgName); _part = _dlg.AddParticipant(_partName); _entry1 = _dlg.AddEntry(_part, entryContent); _entry2 = _dlg.AddEntry(_part, entryContent2); _choice = _dlg.AddChoice(_entry1, choiceContent, _entry2); }
private void ChoiceListViewItemSelected(object parameter) { DialogueChoice dialogueChoice = parameter as DialogueChoice; if (dialogueChoice != null) { GameManager.Current.ChoiceSelected(dialogueChoice); } }
public ConnectorViewModel(CommandExecutor cmdExec, DialogueChoice dlgChoice, NodeViewModel parent) { _cmdExec = cmdExec; _dialogueChoice = dlgChoice; ParentNode = parent; AttachedConnections = new List <ConnectionViewModel>(); }
public IEnumerator DisplayAskCharacterPrompt(DialogueChoice DialogueChoiceOption, Action <int> callback) { askCharacterView.gameObject.SetActive(true); askCharacterView.UpdatePrompt(DialogueChoiceOption.prompt, DialogueChoiceOption.options, SetChoice); yield return(new WaitUntil(() => choice != -1)); askCharacterView.gameObject.SetActive(false); callback?.Invoke(choice); ResetChoice(); }
public IEnumerator <YieldInstruction> askDungeonQuestion(int dungeon, Action yes, Action no) { ZoneData zoneEntry = DataManager.Instance.GetZone(dungeon); DialogueChoice[] choices = new DialogueChoice[2]; choices[0] = new DialogueChoice(Text.FormatKey("DLG_CHOICE_YES"), yes); choices[1] = new DialogueChoice(Text.FormatKey("DLG_CHOICE_NO"), no); DungeonEnterDialog dialog = new DungeonEnterDialog(Text.FormatKey("DLG_ASK_ENTER_DUNGEON", zoneEntry.Name.ToLocal()), dungeon, false, choices, 0, 1); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(dialog))); }
public void CreateChoice(EventChoice e) { if (e.itemRequirement != null) { useItem.Init(e, manager); } DialogueChoice choice = Instantiate <DialogueChoice>(chiocePrefab, choiceContent.transform); choice.Init(e, manager); choices.Add(choice); }
public void TriggerDialogue(string scene, int result, bool reset = false) { dialogueScene = (dialogueScene == null ? scene : dialogueScene); if (IsDialogueActive && scene == dialogueScene && !reset) // this dialogue already triggered return; if (scene == "END") throw new Exception("Scene called special value END"); lineIndex = 0; lineFinished = false; lines = XmlDialogueReader.LoadDialogue(scene); choice = lines[lines.Length - 1].Choice; ActivateDialogueGUI(true); DisplayLine(lines[0]); choiceLoaded = false; }
public void changeText( DialogueChoice current) { currentDC = current; theDialogue.text = current.line; theChoice1.text = current.gotoLine1; theChoice2.text = current.gotoLine2; if (current.gotoId3 != null) { theChoice3.gameObject.SetActive( true ); theChoice3.text = current.gotoLine3; } else { theChoice3.gameObject.SetActive( false ); } }
public static DialogueChoice getAlexDialogueChoiceFromId(int id) { DialogueChoice toReturn = Alex_choices [0]; for (int i = 0; i < Alex_choices.Length; i++) { if (id == Alex_choices[i].id) { toReturn = Alex_choices[i]; break; } } return(toReturn); }
private void OnTextInput(string inputText) { DialogueChoice selectedOption = ChoiceSystem.DialogueChoices.Last(); foreach (DialogueChoice option in ChoiceSystem.DialogueChoices) { if (option.Text.Contains(inputText)) { selectedOption = option; } } ChoiceSystem.SelectChoice(selectedOption); }
public void DungeonChoice(int dungeonid) { try { m_choiceresult = null; ZoneData zoneEntry = DataManager.Instance.GetZone(dungeonid); DialogueChoice[] choices = new DialogueChoice[2]; choices[0] = new DialogueChoice(Text.FormatKey("DLG_CHOICE_YES"), () => { m_choiceresult = true; }); choices[1] = new DialogueChoice(Text.FormatKey("DLG_CHOICE_NO"), () => { m_choiceresult = false; }); m_curchoice = new DungeonEnterDialog(Text.FormatKey("DLG_ASK_ENTER_DUNGEON", zoneEntry.GetColoredName()), dungeonid, false, choices, 0, 1); } catch (Exception e) { DiagManager.Instance.LogInfo(String.Format("ScriptUI.DungeonMenu(): Encountered exception:\n{0}", e.Message)); } }
private void Start() { choices = new Word[2]; Vector3 startPoint = pastDialogue.EndPoint(); DialogueChoice dc = new DialogueChoice(); wordPrefab.GetComponent <Word>().word = "Who are you?"; choices[0] = GameObject.Instantiate(wordPrefab, transform).GetComponent <Word>(); wordPrefab.GetComponent <Word>().word = "How did I get here?"; choices[1] = GameObject.Instantiate(wordPrefab, transform).GetComponent <Word>(); choices[0].transform.position = startPoint + new Vector3(2.0f, 3.5f); choices[0].GetComponent <Text>().color = new Color(0.2f, 0.6f, 0.2f); choices[1].transform.position = startPoint + new Vector3(4.5f, -1.0f); choices[1].GetComponent <Text>().color = new Color(0.2f, 0.6f, 0.2f); transform.position = pastDialogue.transform.position; }
// Takes the information from the text file and puts it into separte nodes. Separate nodes are denoted by '~'. private void ParseInformation() { InitializeVariables(); List <DialogueChoice> playerChoices = new List <DialogueChoice>(); for (int lI = 0; lI < textLines.Length; lI++) { string currentLine = textLines[lI].Trim(); int lineLength = currentLine.Length; if (char.IsNumber(currentLine[0])) { int.TryParse(currentLine, out nodeID); } else if (IsCharacterName(currentLine)) { characterName = currentLine; } else if (currentLine[0] == '*') { if (currentLine[lineLength - 2] == '-') { linkedNode = -1; } else { linkedNode = (int)char.GetNumericValue(currentLine[lineLength - 1]); } currentLine = currentLine.Remove(lineLength - 2); DialogueChoice newChoice = new DialogueChoice(currentLine, linkedNode); playerChoices.Add(newChoice); } else if (currentLine.Equals("~")) { DialogueNode newNode = new DialogueNode(nodeID, characterName, prompt, playerChoices); dialogueNodes.Add(newNode); playerChoices.Clear(); prompt = ""; } else { prompt += currentLine; } } }
private void Current_RefreshUI(object sender, EventArgs e) { List <DialogueChoice> dialogueChoicesList = null; Conversation runninConversation = GameManager.Current.ConversationsManager.RunningConversation; ConversationNode currentNode = null; Character currentCharacter = null; string text = null; string characterID = null; string characterName = null; if (runninConversation != null && runninConversation.CurrentNode != null) { currentNode = GameManager.Current.ConversationsManager.RunningConversation.CurrentNode; text = currentNode.Text; characterID = currentNode.CharacterID; if (GameManager.Current.Characters.ContainsKey(characterID)) { currentCharacter = GameManager.Current.Characters[characterID]; } if (currentCharacter != null) { characterName = currentCharacter.FullName; } this.CharacterName = characterName; this.CurrentDialogueText = text; this.UpdateCharacterPortrait(currentCharacter.ID); dialogueChoicesList = new List <DialogueChoice>(); foreach (ConversationChoice conversationChoice in currentNode.Choices) { DialogueChoice currentChoice = new DialogueChoice(); currentChoice.ID = conversationChoice.ID; currentChoice.Text = conversationChoice.Text; if (conversationChoice.CanShow) { dialogueChoicesList.Add(currentChoice); } } this.DialogueChoices = dialogueChoicesList.ToArray(); } }
private void ShowCurrentConversationStep() { CurrentDialogue = CurrentTree.dialogue[CurrentStep]; string text = CurrentDialogue.text; if (CurrentDialogue.choices != null && CurrentDialogue.choices.Count > 0) { text += "\n"; for (int i = 0; i < CurrentDialogue.choices.Count; i++) { DialogueChoice choice = CurrentDialogue.choices[i]; text += "\n " + (i + 1).ToString() + ". <color=" + (i == CurrentChoice ? "Blue" : choice.visited ? "DarkBlue" : "Green") + ">" + choice.text + "</color>"; } } Globals.DialogueCanvasController.SetText(text); Globals.DialogueCanvasController.AdjustBustsHighlight(CurrentDialogue.npc == "N"); }
public void changeText(DialogueChoice current) { currentDC = current; theDialogue.text = current.line; theChoice1.text = current.gotoLine1; theChoice2.text = current.gotoLine2; if (current.gotoId3 != null) { theChoice3.gameObject.SetActive(true); theChoice3.text = current.gotoLine3; } else { theChoice3.gameObject.SetActive(false); } }
public NodeViewModel(CommandExecutor cmdExec, DialogueEntry entry, Dialogue dialogue, NetworkViewModel network) { _dialogue = dialogue; _dialogueEntry = entry; _cmdExec = cmdExec; _network = network; incomingConnector = new ConnectorViewModel(_cmdExec, null, this); for (int i = 0; i < entry.NumChoices; ++i) { DialogueChoice choice = entry.Choice(i); if (choice != null) { OutgoingConnectors.Add(new ConnectorViewModel(_cmdExec, choice, this)); } } }
public IEnumerator DisplayPrompt(DialogueChoice DialogueChoiceOption, Action <int> callback) { if (DialogueChoiceOption.isYesNo()) { yield return(StartCoroutine(DisplayYesNoPrompt(DialogueChoiceOption, callback))); } else if (DialogueChoiceOption.isFour()) { yield return(StartCoroutine(DisplayFourSquarePrompt(DialogueChoiceOption, callback))); } else if (DialogueChoiceOption.isTwo()) { yield return(StartCoroutine(DisplayAskCharacterPrompt(DialogueChoiceOption, callback))); } else { yield return(StartCoroutine(DisplayCharacterSelectPrompt(DialogueChoiceOption, callback))); } }
public void getNextChoiceBasedOnBox(int choiceNumber) { int idClickedOn = 0; if (choiceNumber == 1) { idClickedOn = currentDC.gotoId1; } else if (choiceNumber == 2) { idClickedOn = currentDC.gotoId2; } else if (choiceNumber == 3) { idClickedOn = currentDC.gotoId3; } DialogueChoice nextChoice = DialogueManager.getAlexDialogueChoiceFromId(idClickedOn); changeText(nextChoice); }
public void UseDialogueChoice(int index) { Debug.Log("Choice index " + index + " was used"); DialogueChoice choice = activeDialogue.dialogueChoices[index]; //Display answer/response StartCoroutine(TypeSentence(choice.response, false)); HideChoiceButtons(); //Perform choice actions Player.instance.ChangeStat(choice.changes); if (choice.followUpDialogue) { GameManager.instance.AddUpcomingDialogue(choice.followUpDialogue); } //End dialogue button enable activeDialogue = null; continueButton.interactable = true; }
public void OnChoicesStarted(Yarn.OptionSet.Option[] options, ILineLocalisationProvider localisationProvider) { IEnumerable <DialogueChoice> dialogueChoices = options.Select((option) => { string text = localisationProvider.GetLocalisedTextForLine(option.Line); // Sanity check if (text == null) { Debug.LogWarning($"Line {option.Line.ID} doesn't have any localised text."); text = option.Line.ID; } DialogueChoice dialogueChoice = new DialogueChoice() { Text = text, ID = option.ID }; return(dialogueChoice); }); DialogueManager.OnChoicesStarted(dialogueChoices); }
public static DialogueLine[] LoadDialogue(string scene) { var lines = new List<DialogueLine>(); XDocument xml = XDocument.Load("Assets/Dialogue/" + scene + ".xml"); foreach (var eLine in xml.Element("dialogue").Element("lines").Elements()) { XElement text = eLine.Element("text"); lines.Add(new DialogueLine ( Resources.Load<Sprite>("Sprites/" + (string)eLine.Element("portrait")), (string)text, (text.Attribute("speed") == null ? DialogueLine.DEFAULT_SPEED : (float)text.Attribute("speed")), (text.Attribute("name") == null ? DialogueLine.DEFAULT_NAME : (string)text.Attribute("name")) ) ); } var choices = xml.Element("dialogue").Element("choice"); if (choices != null) { var choice = new DialogueChoice(); // temp value int i = 0; foreach (var eLine in choices.Elements()) // not cooperating to let me make a for loop here... wweh { choice.ChoiceText[i] = (string)eLine; string target = (string)eLine.Attribute("target"); choice.Targets.Add((int)eLine.Attribute("id"),(target != null ? target : "END")); i++; } lines[lines.Count - 1].Choice = choice; // choice always lies in the last line of dialogue } return lines.ToArray(); }
public void Show(ScriptableDialogue dialogue, GameObject player) { panel.SetActive(true); // show text welcomeText.text = dialogue.GetText(player); // show choices List <DialogueChoice> choices = dialogue.GetChoices(player); // instantiate/destroy enough slots UIUtils.BalancePrefabs(slotPrefab.gameObject, choices.Count, content); // refresh all choices for (int i = 0; i < choices.Count; ++i) { UIDialogueChoice slot = content.GetChild(i).GetComponent <UIDialogueChoice>(); DialogueChoice choice = choices[i]; slot.button.interactable = choice.interactable; slot.button.GetComponentInChildren <Text>().text = choice.text; slot.button.onClick.SetListener(choice.action); } }
public void DisplayChoice(DialogueChoice dc) { CurrentNode = dc; //show = true; }
public static List<DialogueChoice> getDialogueChoices(int day, List<int> ResponseChildren, Character.Player player) { string childrenString = ""; int childCounter = 0; int id = 0; List<int> children = new List<int>(); int choiceDay = 0; List<Condition> conditions = new List<Condition>(); List<effect> effects = new List<effect>(); string text = ""; int ChoiceCounter = 0; List<DialogueChoice> Choices = new List<DialogueChoice>(); foreach (int child in ResponseChildren) { childCounter += 1; if (childCounter < ResponseChildren.Count) { childrenString = childrenString + "id = " + child + " or "; } else { childrenString = childrenString + "id = " + child; } } string strExpression = "/dialogue/dialogueChoice[(" + childrenString + ") and @day='" + day.ToString() + "']/*"; XPathDocument dialogueFile = new XPathDocument(DialogueFileLocation); XPathNavigator nav = dialogueFile.CreateNavigator(); XPathNodeIterator nodeIter = nav.Select(strExpression); //we've selected all the child dialogue choices. Now we need to read them into dialogueChoice objects. while (nodeIter.MoveNext()) { switch (nodeIter.Current.Name) { case "children": //read and parse this comma delimited string, turn it into a List<int> object String ChildrenString = nodeIter.Current.Value; string[] childrenArray = ChildrenString.Split(','); foreach (string s in childrenArray) { children.Add(Convert.ToInt32(s)); } break; case "condition": //create condition and add it to condition list. Condition condition = new Condition(); //go through condition attribute values and populate the condition object with them. String subject = nodeIter.Current.GetAttribute("subject", ""); condition.Subject = subject; String attribute = nodeIter.Current.GetAttribute("attribute", ""); condition.Attribute = attribute; String upperLimit = nodeIter.Current.GetAttribute("upperLimit", ""); if (upperLimit != "") condition.UpperLimit = Convert.ToInt32(upperLimit); String lowerLimit = nodeIter.Current.GetAttribute("lowerLimit", ""); if (lowerLimit != "") condition.LowerLimit = Convert.ToInt32(lowerLimit); String value = nodeIter.Current.Value; if (value != "") condition.Value = Convert.ToInt32(value); String type = nodeIter.Current.GetAttribute("type", ""); condition.Type = type; String decisionID = nodeIter.Current.GetAttribute("id", ""); if (decisionID != "") condition.DecisionID = Convert.ToInt32(decisionID); conditions.Add(condition); break; case "effect": effect effect = new effect(); String effectType = nodeIter.Current.GetAttribute("type", ""); effect.type = effectType; String effectSubject = nodeIter.Current.GetAttribute("subject", ""); effect.Subject = effectSubject; String effectAttribute = nodeIter.Current.GetAttribute("attribute", ""); effect.Attribute = effectAttribute; String effectChange = nodeIter.Current.GetAttribute("change", ""); if (effectChange != "") effect.change = Convert.ToInt32(effectChange); String effectDecisionId = nodeIter.Current.GetAttribute("id", ""); if (effectDecisionId != "") effect.DecisionID = Convert.ToInt32(effectDecisionId); String decisionValue = nodeIter.Current.Value; int n; if (Int32.TryParse(decisionValue, out n)) effect.DecisionValue = Convert.ToInt32(decisionValue); String effectDescription = nodeIter.Current.GetAttribute("desc", ""); effect.Description = effectDescription; effects.Add(effect); break; case "text": text = nodeIter.Current.Value; break; case "id": //add one to the response counter - we got a new response! ChoiceCounter += 1; id = Convert.ToInt32(nodeIter.Current.Value); //Now we can create a new response object and fill it. DialogueChoice Choice = new DialogueChoice(); Choice.Day = day; Choice.ID = id; Choice.Text = text; Choice.children = children; Choice.Conditions = conditions; Choice.Effects = effects; //Add new response to response list Choices.Add(Choice); //reset values to default for the next dialogue id = 0; text = ""; children = new List<int>(); conditions = new List<Condition>(); break; } } List<DialogueChoice> parsedChoices = ParseChoices(Choices, player); return parsedChoices; }
public static void parseEffects(DialogueChoice choice) { if (choice.Effects.Count > 0) { foreach (effect e in choice.Effects) { switch (e.type) { case "immediate": // look for subject, attribute, etc if (e.Subject != null && e.Attribute != null && e.change != null) { Character.ModifyCharacter(e.Subject, e.Attribute, e.change); } break; case "timed": // look for subject attribute, howlong, etc break; case "decision": //look for decisionID, decision value, etc Character.decision decision = new Character.decision(); decision.id = e.DecisionID; decision.value = Convert.ToInt32(e.DecisionValue); decision.description = e.Description; break; } } } }
private DialogueChoice ProcessNodeChoice() { DialogueChoice ChoiceNode = new DialogueChoice(); string line; do { line = GetValidLine(); if(line != null) { if(line[0] == '}') break; else { line = line.ToLower(); if(line.CompareTo("option") == 0) { Choice c = ProcessChoiceOption(); if(c != null) ChoiceNode.AddChoice(c); } else AttemptToAddJump(line.ToLower().Split('=')); } } } while(line != null); return ChoiceNode; }
private void setChoiceButton(GameObject button, DialogueChoice choice) { button.SetActive(true); button.GetComponent <Text>().text = choice.getChoiceText(); button.GetComponent <Button>().onClick.AddListener(delegate { SetSelectedOption(choice.getLinkedNode()); }); }
public static string SaveToJson(DialogueChoice data) { return(JsonUtility.ToJson(data, true)); }
private static void setupAlex() { DialogueChoice dc = new DialogueChoice(); dc.line = "..."; dc.id = 0; dc.gotoLine1 = "Hi"; dc.gotoId1 = 1; dc.gotoLine2 = "Hey"; dc.gotoId2 = 1; dc.gotoLine3 = "Hey, how are you?"; dc.gotoId3 = 2; Alex_choices [0] = dc; dc = new DialogueChoice(); dc.line = "Hi, how are you?"; dc.id = 1; dc.gotoLine1 = "Fine, you?"; dc.gotoId1 = 2; dc.gotoLine2 = "I'm alright, what about you?"; dc.gotoId2 = 2; dc.gotoLine3 = "Not having the best day actually"; dc.gotoId3 = 3; Alex_choices [1] = dc; dc = new DialogueChoice(); dc.line = "I'm feeling great!"; dc.id = 2; dc.gotoLine1 = "Are you enjoying this club?"; dc.gotoId1 = 6; dc.gotoLine2 = "And how is the night treating you so far?"; dc.gotoId2 = 8; dc.gotoLine3 = " "; dc.gotoId3 = 0; Alex_choices [2] = dc; dc = new DialogueChoice(); dc.line = "Really? What happened?"; dc.id = 3; dc.gotoLine1 = "Oh you know, just life."; dc.gotoId1 = 4; dc.gotoLine2 = "Life stuff you know, but I dont wanna bother you with that."; dc.gotoId2 = 7; dc.gotoLine3 = " "; dc.gotoId3 = 0; Alex_choices [3] = dc; dc = new DialogueChoice(); dc.line = "That sucks, did you want something from me?"; dc.id = 4; dc.gotoLine1 = "..I guess not."; dc.gotoId1 = 5; dc.gotoLine2 = "Yeah, you seem nice, just wanted someone to talk to."; dc.gotoId2 = 7; dc.gotoLine3 = " "; dc.gotoId3 = 0; Alex_choices [4] = dc; dc = new DialogueChoice(); dc.line = "K, bye!"; dc.id = 5; dc.gotoLine1 = "...bye."; dc.gotoId1 = 0; dc.gotoLine2 = " "; dc.gotoId2 = 0; dc.gotoLine3 = " "; dc.gotoId3 = 0; Alex_choices [5] = dc; dc = new DialogueChoice(); dc.line = "Yeah, the music is really good!"; dc.id = 6; dc.gotoLine1 = "It sure is."; dc.gotoId1 = 10; dc.gotoLine2 = "You seem really nice, can I pay you a drink?"; dc.gotoId2 = 8; dc.gotoLine3 = "You like this kind of music? That's sad."; dc.gotoId3 = 5; Alex_choices [6] = dc; dc = new DialogueChoice(); dc.line = "Sorry about that, I just don't like when people keep complaining about their problems you know?"; dc.id = 7; dc.gotoLine1 = "Yeah, I understand... Anyway, are you enjoying the club?"; dc.gotoId1 = 6; dc.gotoLine2 = "That's okay! Maybe I can pay you a drink to make it up for that?"; dc.gotoId2 = 8; dc.gotoLine3 = " "; dc.gotoId3 = 0; Alex_choices [7] = dc; dc = new DialogueChoice(); dc.line = "Uhmm, I don't know... I don't really know you."; dc.id = 8; dc.gotoLine1 = "Oh, that's okay..."; dc.gotoId1 = 5; dc.gotoLine2 = "Well, if you accept my offer you will."; dc.gotoId2 = 9; dc.gotoLine3 = " "; dc.gotoId3 = 0; Alex_choices [8] = dc; dc = new DialogueChoice(); dc.line = "...Okay, sure."; dc.id = 9; dc.gotoLine1 = ""; dc.gotoId1 = 0; dc.gotoLine2 = ""; dc.gotoId2 = 0; dc.gotoLine3 = " "; dc.gotoId3 = 0; Alex_choices [9] = dc; dc = new DialogueChoice(); dc.line = "What about you? Are you enjoying it?"; dc.id = 10; dc.gotoLine1 = "I guess it's alright."; dc.gotoId1 = 11; dc.gotoLine2 = "I am, but I would enjoy it more if you had a drink with me!"; dc.gotoId2 = 8; dc.gotoLine3 = " "; dc.gotoId3 = 0; Alex_choices [10] = dc; dc = new DialogueChoice(); dc.line = "Oh c'mon! Let's get a drink then, maybe it'll make it better."; dc.id = 11; dc.gotoLine1 = "Sure, that would be awesome!"; dc.gotoId1 = 0; dc.gotoLine2 = "Nah, i'm ok."; dc.gotoId2 = 5; dc.gotoLine3 = " "; dc.gotoId3 = 0; Alex_choices [11] = dc; }
public ConnectionViewModel(CommandExecutor cmdExe, DialogueChoice choice) { _cmdExe = cmdExe; _choice = choice; }
static DialogueTreeNode CreateNodeFromFile(string path, string fileName) { DialogueTreeNode node = new DialogueTreeNode(); string[] lines = System.IO.File.ReadAllLines(path + fileName); List <string> sentences = new List <string>(); int index = 0; for ( ; index < lines.Length; index++) { if (lines[index].Contains("Choice:")) { break; } if (lines[index].Length > 0) { sentences.Add(lines[index]); } } List <DialogueChoice> choices = new List <DialogueChoice>(); for (; index < lines.Length; index++) { if (lines[index].Contains("Choice:")) { DialogueChoice choice = new DialogueChoice(); //Is this a success/failure choice? if (lines[index].Contains("[") && lines[index].Contains("]")) { choice.requirement = new DialogueRequirement(); string requirementAsString = lines[index].Split('[')[1].Split(']')[0]; string[] split = requirementAsString.Split(' '); choice.requirement.type = split[0]; choice.requirement.points = int.Parse(split[1]); choice.successSentence = lines[index]; choice.failureSentence = lines[index + 1]; choice.successNext = CreateNodeFromFile(path, lines[index + 2]); choice.failureNext = CreateNodeFromFile(path, lines[index + 3]); index += 4; } else { choice.successSentence = lines[index]; index++; choice.successNext = CreateNodeFromFile(path, lines[index]); } choices.Add(choice); } } node.sentences = sentences.ToArray(); node.choices = choices.ToArray(); return(node); }
public void SelectChoice(DialogueChoice selectedChoice) { DialogueManager.OnChoiceSelected(selectedChoice); CloseInput(); }
void CallChoices() { if (currentStory.currentChoices.Count <= 0) { return; } int activeQuestsCount = 0; List <Quest> activeQuests = new List <Quest>(); int openQuestsCount = 0; List <Quest> openQuests = new List <Quest>(); if (checkingTopics) { if (QuestSystem.QuestNPC(NPC, out activeQuests)) { activeQuestsCount = activeQuests.Count; } openQuests = Core.Instance.DB.QuestDB.GetOpenQuests(NPC); openQuestsCount = openQuests.Count; checkingTopics = false; } int totalCount = currentStory.currentChoices.Count + activeQuestsCount + openQuestsCount; choices = new DialogueChoice[totalCount]; int elementIndex = 0; int i = 0; while (i < activeQuestsCount) { DialogueChoice choice = Instantiate(choicePrefab, choiceParent).GetComponent <DialogueChoice>(); choice.SetQuestTopic(NPC, activeQuests[i]); choices[elementIndex] = choice; i++; elementIndex++; } i = 0; while (i < openQuestsCount) { DialogueChoice choice = Instantiate(choicePrefab, choiceParent).GetComponent <DialogueChoice>(); choice.SetQuestTopic(NPC, openQuests[i]); choices[elementIndex] = choice; i++; elementIndex++; } i = 0; while (i < currentStory.currentChoices.Count) { DialogueChoice choice = Instantiate(choicePrefab, choiceParent).GetComponent <DialogueChoice>(); choice.SetChoice(NPC, currentStory.currentChoices[i]); choices[elementIndex] = choice; i++; elementIndex++; } }
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 = "f**k off", endAction = SpeechCheckFail }; DialogueMessage failMsg = new DialogueMessage() { name = "Neighborhood Man", dialogue = "f**k 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 NetworkViewModel(CommandExecutor cmdExe, Dialogue dialogue) { _dialogue = dialogue; _cmdExec = cmdExe; if (_dialogue == null) { Debug.Assert(false); return; } var entryToModel = new Dictionary<DialogueEntry, NodeViewModel>(); for (int i = 0; i < _dialogue.NumEntries; ++i) { DialogueEntry entry = _dialogue.Entry(i); if (entry != null) { var model = new NodeViewModel(cmdExe, entry, _dialogue, this); Nodes.Add(model); entryToModel.Add(entry, model); } } for (int i = 0; i < _dialogue.NumChoices; ++i) { DialogueChoice choice = _dialogue.Choice(i); if (choice != null) { var connection = new ConnectionViewModel(cmdExe, choice); Connections.Add(connection); if (choice.SourceEntry != null && choice.DestinationEntry != null) { NodeViewModel srcNode = entryToModel[choice.SourceEntry]; foreach (ConnectorViewModel connector in srcNode.OutgoingConnectors) { if (connector.DialogueChoice.Equals(choice)) { connection.SourceConnector = connector; break; } } NodeViewModel dstNode = entryToModel[choice.DestinationEntry]; connection.DestConnector = dstNode.IncomingConnector; } } } for (int i = 0; i < _dialogue.NumParticipants; ++i) { Participant participant = _dialogue.Participant(i); if (participant != null) { var model = new ParticipantViewModel(cmdExe, participant, _dialogue); Participants.Add(model); } } }
public SetChoiceDestUndoableCommand(ConnectorViewModel destConnector, ConnectionViewModel connection, DialogueChoice choice) { _destConnector = destConnector; _connection = connection; _choice = choice; }