public TopicEntry GetTopic(CreatureEntity collocutor, int conversationIndex, TopicEntry parentTopic, string phrase) { TopicEntry result = null; DialogEntry dlg = Dialog; ConversationEntry curConvers = dlg.GetConversation(conversationIndex); if (parentTopic == null) { result = curConvers.GetTopic(0); } else { for (int i = 0; i < parentTopic.TopicsCount; i++) { TopicEntry subTopic = parentTopic.GetTopic(i); if ((subTopic.Phrase == phrase)) { result = subTopic; break; } } } return(result); }
void unregisterFromEvents(DialogEntry entry) { if (entry != null) { try { entry.DialogEntryChanged -= entry_DialogEntryChanged; } catch { } } }
/// <summary> /// Initializes a new instance of the <see cref="RenderedDialogEntry"/> struct. /// </summary> /// <param name="m">The rendered matrix.</param> /// <param name="renderedElements">The rendered elements this matrix is build of.</param> public RenderedDialogEntry(bool[,] m, IList <RenderElement> renderedElements) { _entry = null; _m = m; _renderedElements = new List <RenderElement>(renderedElements); _horizontalOffset = 0; }
private void registerToEvents(DialogEntry entry) { if (entry != null) { entry.DialogEntryChanged += entry_DialogEntryChanged; } }
private static ChatMapper.DialogEntry DialogEntryToCmp(DialogueSystem.DialogueEntry entry, bool includeCanvasRect) { ChatMapper.DialogEntry cmpEntry = new DialogEntry(); cmpEntry.ID = entry.id; cmpEntry.IsRoot = entry.isRoot || ((entry.id == 0) && string.Equals(entry.Title, "START")); cmpEntry.IsGroup = entry.isGroup; cmpEntry.NodeColor = string.IsNullOrEmpty(entry.nodeColor) ? "White" : entry.nodeColor; cmpEntry.DelaySimStatus = entry.delaySimStatus; cmpEntry.FalseCondtionAction = GetValidFalseConditionAction(entry.falseConditionAction); cmpEntry.ConditionPriority = entry.conditionPriority.ToString(); cmpEntry.Fields = FieldsToCmp(entry.fields); AddRequiredDialogEntryFields(cmpEntry.Fields); cmpEntry.Fields.ForEach(cmpField => { if (cmpField.Title.StartsWith("Dialogue Text")) { cmpField.Type = "Localization"; } }); if (includeCanvasRect) { AddCanvasRectField(entry, cmpEntry); } cmpEntry.OutgoingLinks = LinksToCmp(entry.outgoingLinks); foreach (var link in cmpEntry.OutgoingLinks) { link.OriginConvoID = entry.conversationID; link.OriginDialogID = entry.id; } cmpEntry.ConditionsString = entry.conditionsString; cmpEntry.UserScript = entry.userScript; return(cmpEntry); }
/// <summary> /// Initializes a new instance of the <see cref="RenderedDialogEntry"/> struct. /// </summary> /// <param name="entry">The dialog entry that was rendered.</param> /// <param name="m">The rendered matrix.</param> public RenderedDialogEntry(DialogEntry entry, bool[,] m) { _entry = entry; _m = m; _renderedElements = null; _horizontalOffset = 0; }
private static void AddBranchToNode(DialogEntry parent, DialogEntry child) { var parentBranches = parent.Branches.Length; Array.Resize(ref parent.Branches, parentBranches + 1); parent.Branches[parentBranches] = child; }
public void AddEntry(DialogEntry entry) { queue.Enqueue(entry); if (!active) { TurnOn(); } }
private void CreateNewNode(Vector2 position, DialogEntry node) { var createdNode = CreateNode(position, $"Title {Context.DialogEntries.Count.ToString()}"); if (node != null) { AddBranchToNode(node, createdNode); } }
/// <summary> /// Initializes a new instance of the <see cref="RadioButton_DialogEntry" /> class. /// </summary> /// <param name="ID">The unique identifier.</param> /// <param name="text">The text that is displayed.</param> /// <param name="help">The help text explaining the functionality behind this entry.</param> /// <param name="status">The status of the Radiobutton (should be DialogEntryStatus.Checked or DialogEntryStatus.Unchecked).</param> /// <param name="parentDialog">The parent dialog this entry is related to. Can be <c>null</c> - when added to a Dialog this Field will be set automatically.</param> /// <param name="parentEntry">The parent entry (must be some kind of group type).</param> public RadioButton_DialogEntry( string ID, string text, string help = "...", DialogEntryStatus status = DialogEntryStatus.Unchecked, DialogEntry parentEntry = null, Dialog parentDialog = null) : base(ID, text, help, DialogEntryType.RadioButton, status, parentEntry, parentDialog) { Status = status; }
public void Reset() { m_entry = null; m_text.text = null; m_isBackButton = false; m_backToId = 0; m_isFeatureButton = false; m_isNextPageButton = false; m_featureFunction = null; m_enabled = true; m_button.IsEnabled = true; }
/// <summary> /// Gets the position within the rendered content matrix of a certain entry. /// </summary> /// <param name="entry">The entry to look for its position.</param> /// <returns>The bounding box, including position, of the searched entry or an empty bounding box.</returns> public virtual System.Drawing.Rectangle GetEntryPositionWithinContent(DialogEntry entry) { System.Drawing.Rectangle bb = new System.Drawing.Rectangle(); if (entry != null) { var rendObj = GetRenderedElementOfEntry(entry); if (!rendObj.IsEmpty()) { bb = new Rectangle(rendObj.X, rendObj.Y, rendObj.Width, rendObj.Height); } } return(bb); }
IEnumerator SlowTypying(DialogEntry entry) { AudioClip clip = clips [Random.Range(0, clips.Length)]; source.clip = clip; source.volume = 0.1f; source.Play(); foreach (var x in entry.content) { content.text += x; yield return(new WaitForSeconds(.05f)); } source.DOFade(0f, 1f).OnComplete(() => { source.Stop(); }); }
private void UpdateConversations() { fConversations.Items.BeginUpdate(); fConversations.Items.Clear(); SentientBrain b = (SentientBrain)fCollocutor.Brain; DialogEntry dlg = b.Dialog; int num = dlg.ConversationsCount; for (int i = 0; i < num; i++) { fConversations.Items.Add(dlg.GetConversation(i).Name, null); } fConversations.Items.EndUpdate(); fTextBox.Lines.Text = ""; }
public void SetEntry(DialogEntry p_entry, GameObject p_dialogView) { m_entry = p_entry; if (p_entry.Text != null) { String localizableText = LocaManager.GetText(p_entry.Text.LocaKey); m_text.text = m_index + ". " + localizableText; } else { m_text.text = "no text found"; } if (p_entry.State == EDialogState.DISABLED) { m_enabled = false; m_button.IsEnabled = false; } }
public void nextDialog() { DialogEntry dialogEntry = currentDialog.getNextDialog(); if (dialogEntry != null) { string dialog = dialogEntry.dialog; textMeshUguu.text = dialog; SpriteRenderer sprite = portraits.transform.Find(dialogEntry.speakingCharacterName).GetComponent <SpriteRenderer>(); image.sprite = sprite.sprite; } else { textPanelGameObject.SetActive(false); } if (!currentDialog.hasMoreDialog()) { buttonText.text = "Close"; } }
/// <summary> /// Gets the rendered element object of a specific entry. /// </summary> /// <param name="entry">The entry to search for its rendered counterpart.</param> /// <returns>The rendered</returns> public virtual RenderElement GetRenderedElementOfEntry(DialogEntry entry) { lock (_renderedElementLock) { if (entry != null && RenderedElements != null && RenderedElements.Count > 0) { foreach (RenderElement item in RenderedElements) { object value = item.GetValue(); DialogEntry valueEntry = value as DialogEntry; if (valueEntry != null && valueEntry == entry) { return(item); } } } } return(new RenderElement()); }
IEnumerator DisplayingText() { while (queue.Count != 0) { DialogEntry entry = queue.Dequeue(); _name.text = entry.name; avatar.sprite = entry.avatar; yield return(StartCoroutine(ActivateBox())); yield return(StartCoroutine(SlowTypying(entry))); yield return(new WaitForSeconds(1)); yield return(StartCoroutine(DeactivateBox())); yield return(new WaitForSeconds(2)); } active = false; }
static EitriBrain() { SfDialog = new DialogEntry(); ConversationEntry defConvers = SfDialog.AddConversation(); defConvers.Name = BaseLocale.GetStr(RS.rs_EitriTopic); TopicEntry rootTopic = defConvers.AddTopic(); rootTopic.Answer = BaseLocale.GetStr(RS.rs_EitriSaid) + "\"" + BaseLocale.GetStr(RS.rs_Eitri1) + "\"."; TopicEntry topic = rootTopic.AddTopic(); topic.Condition = "player.hasItem('PlatinumAnvil')"; topic.Phrase = BaseLocale.GetStr(RS.rs_Eitri_Yes); topic.Answer = BaseLocale.GetStr(RS.rs_Eitri3) + " " + BaseLocale.GetStr(RS.rs_Eitri4); topic.Action = "player.transferItem(NPC, 'PlatinumAnvil'); NPC.transferItem(player, 'DwarvenArm');"; topic = rootTopic.AddTopic(); topic.Phrase = BaseLocale.GetStr(RS.rs_Eitri_No); topic.Answer = BaseLocale.GetStr(RS.rs_Eitri2); }
/// <summary> /// Renders a content object into an boolean matrix; /// while <c>true</c> values indicating raised pins and <c>false</c> values indicating lowered pins /// </summary> /// <param name="view">The frame to render in. This gives access to the space to render and other parameters. Normally this is a IBrailleIOViewRange.</param> /// <param name="content">The content to render.</param> /// <returns> /// A two dimensional boolean M x N matrix (bool[M,N]) where M is the count of rows (this is height) /// and N is the count of columns (which is the width). /// Positions in the Matrix are of type [i,j] /// while i is the index of the row (is the y position) /// and j is the index of the column (is the x position). /// In the matrix <c>true</c> values indicating raised pins and <c>false</c> values indicating lowered pins /// </returns> public virtual bool[,] RenderMatrix(IViewBoxModel view, object content) { bool[,] m = emptyMatrix; if (view != null && view.ContentBox.Width > 0 && content != null && content is DialogEntry) { DialogEntry entry = content as DialogEntry; if (entry != null) { switch (entry.Type) { case DialogEntryType.Submenu: m = GetTacton("dialogSubmenu"); //dialogSubmenu; break; case DialogEntryType.Group: break; case DialogEntryType.Checkbox: m = entry.Status.HasFlag(DialogEntryStatus.Checked) ? GetTacton("checkActivated") : GetTacton("check"); //checkActivated : check; break; case DialogEntryType.RadioButton: m = entry.Status.HasFlag(DialogEntryStatus.Checked) ? GetTacton("radioActivated") : GetTacton("radio"); //radioActivated : radio; break; case DialogEntryType.Button: m = GetTacton("button"); //button; break; case DialogEntryType.EditField: break; default: break; } if (entry.Status.HasFlag(DialogEntryStatus.Disabled)) { // TODO: how to mark elements as disabled; even if they have already an icon. m = GetTacton("disabled"); //disabled; } //else if (entry.Status.HasFlag(DialogEntryStatus.Checked)) //{ // if(entry.Type == DialogEntryType.Checkbox) // m = checkActivated; //} //else if (entry.Status.HasFlag(DialogEntryStatus.Unchecked)) //{ // m = dialogUnchecked; //} else if (entry.Status.HasFlag(DialogEntryStatus.Activated)) { m = GetTacton("dialogActive"); //dialogActive; } // TODO: SUBMENU etc. } } return(m); }
private void OnGUI() { GUILayout.Label(m_WatsonIcon); m_ScrollPos = EditorGUILayout.BeginScrollView(m_ScrollPos); if (m_Refreshing) { EditorGUI.BeginDisabledGroup(true); GUILayout.Button("Refreshing..."); EditorGUI.EndDisabledGroup(); } else if (m_Dialogs == null || GUILayout.Button("Refresh")) { OnRefresh(); } EditorGUILayout.LabelField("Dialogs:"); EditorGUILayout.BeginVertical(); EditorGUI.indentLevel += 1; if (m_Dialogs != null) { for (int i = 0; i < m_Dialogs.dialogs.Length; ++i) { BeginWindows(); EditorGUILayout.BeginHorizontal(); DialogEntry d = m_Dialogs.dialogs[i]; EditorGUILayout.LabelField(string.Format("Name: {0}, ID: {1}", d.name, d.dialog_id)); if (GUILayout.Button("Delete")) { if (EditorUtility.DisplayDialog("Confirm", string.Format("Confirm delete of dialog {0}", d.dialog_id), "YES", "NO")) { m_Dialog.DeleteDialog(d.dialog_id, OnDeleteDialog); } } if (GUILayout.Button("Download")) { var path = EditorUtility.SaveFilePanel("Save Dialog", m_CurrentDirectory, "Dialog", "xml"); if (!string.IsNullOrEmpty(path)) { m_CurrentDirectory = Path.GetDirectoryName(path); m_Dialog.DownloadDialog(d.dialog_id, path, OnDownloadDialog); } } EditorGUILayout.EndHorizontal(); EndWindows(); } } EditorGUILayout.EndVertical(); EditorGUI.indentLevel -= 1; EditorGUILayout.LabelField("Upload Dialog:"); EditorGUI.indentLevel += 1; m_NewDialogName = EditorGUILayout.TextField("Name", m_NewDialogName); if (GUILayout.Button("Upload")) { var path = EditorUtility.OpenFilePanel("Select Dialog File", m_CurrentDirectory, "xml"); if (!string.IsNullOrEmpty(path)) { m_CurrentDirectory = Path.GetDirectoryName(path); if (string.IsNullOrEmpty(m_NewDialogName)) { m_NewDialogName = Path.GetFileNameWithoutExtension(path); } if (!m_Dialog.UploadDialog(m_NewDialogName, OnUploadDialog, path)) { Log.Error("DialogEditor", "Failed to upload dialog."); } } m_NewDialogName = null; } EditorGUI.indentLevel -= 1; EditorGUILayout.EndScrollView(); EndWindows(); }
public void Update(Dialog newDialog) { if (newDialog.m_entries == null || newDialog.m_entries.Length == 0) { return; // Not implemented } var result = new LinkedList <DialogEntry>(m_entries); var current = new Dictionary <String, LinkedListNode <DialogEntry> >(m_entries.Length); if (result.Count > 0) { for (var node = result.First; node != null; node = node.Next) { current[node.Value.GetKeyFromText()] = node; } } foreach (DialogEntry ent in newDialog.m_entries) { DialogEntry entry = ent; if (entry.m_injection == null) { result.AddLast(entry); } else { // Remove injection to avoid memory growing DialogEntryInjection injection = entry.m_injection; entry.m_injection = null; LinkedListNode <DialogEntry> node; if (current.TryGetValue(injection.TextKey, out node)) { switch (injection.InjectionType) { case EDialogInjectionType.InsertAfter: result.AddAfter(node, entry); break; case EDialogInjectionType.InsertBefore: result.AddBefore(node, entry); break; case EDialogInjectionType.Replace: result.AddAfter(node, entry); result.Remove(node); break; default: throw new NotImplementedException(injection.InjectionType.ToString()); } } else { result.AddLast(entry); LegacyLogger.LogError($"Cannot find injection target [{injection.TextKey}] in the dialog."); } } } m_entries = result.ToArray(); }
public IEnumerator RunDialog(RuntimeAnimatorController[] protagonist, DialogEntry[] dialogLine, System.Action<bool> callback) { dialogUI.SetActive (true); standardUI.SetActive (false); int currentLine = 0; Image leftSprite = leftPortrait.GetComponent<Image> (); Image rightSprite = rightPortrait.GetComponent<Image> (); Color leftColor = leftSprite.color; Color rightColor = rightSprite.color; // Initialisation leftPortrait.runtimeAnimatorController = protagonist [dialogLine [currentLine].numCharacter]; rightPortrait.runtimeAnimatorController = protagonist [dialogLine [currentLine].numCharacter]; // Tant qu'on n'a pas atteint la fin du dialogue, on défile while (currentLine < dialogLine.Length) { dialogText.text = dialogLine [currentLine].textLine; if (dialogLine [currentLine].portraitPosition == DialogEntry.PortraitPosition.left) { rightColor.a = 0.25f; rightSprite.color = rightColor; leftColor.a = 1; leftSprite.color = leftColor; leftPortrait.runtimeAnimatorController = protagonist [dialogLine [currentLine].numCharacter]; leftPortrait.enabled = true; rightPortrait.enabled = false; } else if (dialogLine [currentLine].portraitPosition == DialogEntry.PortraitPosition.right) { rightColor.a = 1; rightSprite.color = rightColor; leftColor.a = 0.25f; leftSprite.color = leftColor; rightPortrait.runtimeAnimatorController = protagonist [dialogLine [currentLine].numCharacter]; rightPortrait.enabled = true; leftPortrait.enabled = false; } // Si on appuie sur une touche, on affiche l'entrée suivante if (Input.GetMouseButtonDown (0)) currentLine++; yield return null; } dialogUI.SetActive (false); standardUI.SetActive (true); callback (true); }
private static void PopulateDialogEntry(NodeEntry nodeEntry, Node node, Dictionary <Node, int> nodeMap) { ValidateDialog(node); // assign node entry data if validated nodeEntry.nodeType = NodeType.Dialog; nodeEntry.NID = nodeMap[node]; nodeEntry.dialogs = new List <DialogEntry>(); DialogEntry tempDialogEntry = new DialogEntry(); SDEContainer tempChild = node.childContainer; if (tempChild != null) { nodeEntry.dialogs.Add(tempDialogEntry); while (tempChild != null) { // validate every DialogBox ValidateDialogBox((DialogBox)tempChild); // assign values if validated tempDialogEntry.text = ((DialogBox)tempChild).textArea.text; // get dialog flags tempDialogEntry.flags = new List <FlagEntry>(); Node interruptNode = DialogBoxManager.GetInterruptNode(tempChild.outPoint); if (interruptNode == null) { throw new UnityException("EXPORT ERROR: Dialog Node is missing attached Interrupt Node!"); } ValidateInterrupt(interruptNode); // set the default outpoint if there is one and if it's connected if (interruptNode.outPoint != null && interruptNode.outPoint.connections.Count > 0) { tempDialogEntry.outPointNID = nodeMap[(Node)interruptNode.outPoint.connections[0].inPoint.parent]; } SDEContainer interrupt = interruptNode.childContainer; FlagEntry tempFlagEntry; while (interrupt != null) { ValidateDialogInterrupt((DialogInterrupt)interrupt); // build flag entry tempFlagEntry = new FlagEntry(); tempFlagEntry.flag = ((DialogInterrupt)interrupt).label.text; tempFlagEntry.outPointNID = nodeMap[(Node)interrupt.outPoint.connections[0].inPoint.parent]; // add the completed entry to the current dialog entry's flaglist tempDialogEntry.flags.Add(tempFlagEntry); // assign to continue traversal interrupt = interrupt.child; } // assign to continue traversal tempChild = tempChild.child; if (tempChild != null) { tempDialogEntry = new DialogEntry(); nodeEntry.dialogs.Add(tempDialogEntry); } } } }
static VictimBrain() { SfAgnarDialog = new DialogEntry(); ConversationEntry defConvers = SfAgnarDialog.AddConversation(BaseLocale.GetStr(RS.rs_Sacrifice)); TopicEntry rootTopic = defConvers.AddTopic(); rootTopic.Answer = BaseLocale.GetStr(RS.rs_Agnar_IsStrungUp) + " " + BaseLocale.GetStr(RS.rs_VictimPleads); TopicEntry topic1 = rootTopic.AddTopic(); topic1.Phrase = BaseLocale.GetStr(RS.rs_Agnar_KickOutStump); topic1.Answer = BaseLocale.GetStr(RS.rs_SacrificeAward); topic1.Action = "NPC.sacrificeVictim();"; TopicEntry topic2 = rootTopic.AddTopic(); topic2.Phrase = BaseLocale.GetStr(RS.rs_SetHimFree); topic2.Answer = BaseLocale.GetStr(RS.rs_VictimFree); topic2.Action = "NPC.freeVictim();"; TopicEntry topic3 = rootTopic.AddTopic(); topic3.Phrase = BaseLocale.GetStr(RS.rs_DoNothing); topic3.Answer = ""; SfHaddingrDialog = new DialogEntry(); defConvers = SfHaddingrDialog.AddConversation(BaseLocale.GetStr(RS.rs_Sacrifice)); rootTopic = defConvers.AddTopic(); rootTopic.Answer = BaseLocale.GetStr(RS.rs_Haddingr_IsPinned) + " " + BaseLocale.GetStr(RS.rs_VictimPleads); topic1 = rootTopic.AddTopic(); topic1.Phrase = BaseLocale.GetStr(RS.rs_Haddingr_TwistSpear); topic1.Answer = BaseLocale.GetStr(RS.rs_SacrificeAward); topic1.Action = "NPC.sacrificeVictim();"; topic2 = rootTopic.AddTopic(); topic2.Phrase = BaseLocale.GetStr(RS.rs_SetHimFree); topic2.Answer = BaseLocale.GetStr(RS.rs_VictimFree); topic2.Action = "NPC.freeVictim();"; topic3 = rootTopic.AddTopic(); topic3.Phrase = BaseLocale.GetStr(RS.rs_DoNothing); topic3.Answer = ""; SfKetillDialog = new DialogEntry(); defConvers = SfKetillDialog.AddConversation(BaseLocale.GetStr(RS.rs_Sacrifice)); rootTopic = defConvers.AddTopic(); rootTopic.Answer = BaseLocale.GetStr(RS.rs_Ketill_IsDangling) + " " + BaseLocale.GetStr(RS.rs_VictimPleads); topic1 = rootTopic.AddTopic(); topic1.Phrase = BaseLocale.GetStr(RS.rs_Ketill_DrownHim); topic1.Answer = BaseLocale.GetStr(RS.rs_SacrificeAward); topic1.Action = "NPC.sacrificeVictim();"; topic2 = rootTopic.AddTopic(); topic2.Phrase = BaseLocale.GetStr(RS.rs_SetHimFree); topic2.Answer = BaseLocale.GetStr(RS.rs_VictimFree); topic2.Action = "NPC.freeVictim();"; topic3 = rootTopic.AddTopic(); topic3.Phrase = BaseLocale.GetStr(RS.rs_DoNothing); topic3.Answer = ""; }
/// <summary> /// Determines whether the entry is visible or not. /// </summary> /// <param name="entry">The entry.</param> /// <param name="view">The view to check for (BrailleIoViewRange).</param> /// <returns> /// -1 if not visible; 0 if party visible, and 1 if fully visible. /// </returns> public virtual int IsEntryVisible(DialogEntry entry, IViewBoxModel view = null) { return(IsEntryVisible(GetRenderedElementOfEntry(entry), view)); }
/// <summary> /// Makes the entry visible in the given view. /// If an entry is outside the visible area and the view is <see cref="BrailleIO.Interface.IPannable" />, /// the offsets are adapted to make the entry visible. /// </summary> /// <param name="entry">The entry to make visible.</param> /// <param name="view">The view.</param> /// <param name="vertical">if set to <c>true</c> adapt view in vertical direction.</param> /// <param name="horizontal">if set to <c>true</c> adapt view in horizontal direction.</param> /// <returns> /// <c>true</c> if the entry would be visible; otherwise, <c>false</c>. /// </returns> /// <remarks> /// After a returning <c>true</c> you have to force an rerendering. /// </remarks> public virtual bool MakeEntryVisible(DialogEntry entry, IViewBoxModel view = null, bool vertical = true, bool horizontal = false) { return(MakeEntryVisible(GetRenderedElementOfEntry(entry), view)); }
public void LoadId(string id) { DestroyTexts(); if (id == "") { Debug.Log("Last id in dialogTree, going to next scene"); SceneManager.LoadScene("End"); return; } DialogEntry DE = new DialogEntry(); bool found = false; foreach (var de in dialogTree) { if (de.id.Equals(id)) { found = true; DE = de; } } if (!found) { Debug.LogError(id + " not found in dialogTree."); } if (DE.id != id) { Debug.LogError("ID " + id + " not found in dialogTree"); return; } if (DE.nextIds != null) { if (DE.nextIds.Length > 1) { int count = 0; for (int i = 0; i < DE.nextIds.Length; i++) { foreach (var de in dialogTree) { if (de.id.Equals(DE.nextIds[i])) { if (!de.used) { bool check = true; if (de.stateDependency != null) { for (int j = 0; j < de.stateDependency.Length; j++) { if (!GameStates.GetState(de.stateDependency[j])) { check = false; } } } if (check) { GameObject go = Instantiate(ButtonPrefab, UiPannel.transform); go.transform.Find("Text").GetComponent <Text>().text = de.text; go.GetComponent <Button>().onClick.AddListener(delegate { this.LoadId(de.id); }); Vector3 pos = go.transform.localPosition; if (de.needsInterest != 0 && de.interestValue != 0) { if (GameStates.InterestLevel >= de.needsInterest) { go.GetComponent <Button>().onClick.AddListener(delegate { GameStates.InterestLevel += de.interestValue; }); } else { go.GetComponent <Button>().onClick.AddListener(delegate { GameStates.InterestLevel -= de.interestValue; }); } } pos.y -= ButtonVertOffset * count; go.transform.localPosition = pos; count++; } } } } } } else { // display text GameObject go = Instantiate(TextPrefab, UiPannel.transform); go.transform.Find("Text").GetComponent <Text>().text = DE.text; string next = ""; if (DE.nextIds != null) { next = DE.nextIds[0]; } go.GetComponent <Button>().onClick.AddListener(delegate { this.LoadId(next); }); if (DE.needsInterest != 0 && DE.interestValue != 0) { if (GameStates.InterestLevel >= DE.needsInterest) { go.GetComponent <Button>().onClick.AddListener(delegate { GameStates.InterestLevel += DE.interestValue; }); } else { go.GetComponent <Button>().onClick.AddListener(delegate { GameStates.InterestLevel -= DE.interestValue; }); } } } } else { // display text GameObject go = Instantiate(TextPrefab, UiPannel.transform); go.transform.Find("Text").GetComponent <Text>().text = DE.text; string next = ""; if (DE.nextIds != null && DE.nextIds.Length != 0) { next = DE.nextIds[0]; } go.GetComponent <Button>().onClick.AddListener(delegate { this.LoadId(next); }); if (DE.needsInterest != 0 && DE.interestValue != 0) { if (GameStates.InterestLevel >= DE.needsInterest) { go.GetComponent <Button>().onClick.AddListener(delegate { GameStates.InterestLevel += DE.interestValue; }); } else { go.GetComponent <Button>().onClick.AddListener(delegate { GameStates.InterestLevel -= DE.interestValue; }); } } } }
public void Continue() { if (mDialogEntries.Count == 0) { if (mDismissedCallback != null) { mDismissedCallback(0); mDismissedCallback = null; } return; } DialogEntry entry = mDialogEntries[0]; mDialogEntries.RemoveAt(0); AudioPlayer.PlaySound(entry.audio); if (entry.isInfoExchangeRequest) { UIController.Get().ShowMessage( entry.speaker, entry.sprites, entry.message, new string[] { "Yes", "No" }, new UIButtonCallback[] { buttonIndex => { InsertInformationExchange(0); Continue(); }, buttonIndex => { InsertDialogue(0, entry.speaker, entry.sprites, "Alright. Let's talk more later."); Continue(); }, }); } else if (entry.isInfoExchange) { if (entry.speaker.IsPlayer) { // Show prompt, and share the result with other participants of this dialog UIController.Get().AskForSentence(entry.sprites, sentence => { ShareInfo(GameState.Get().Player, sentence); Continue(); }); } else { // The GameState round-clues is guaranteed to be a recent clue that is not the result of combining multiple clues ClueInfo clueInfo = GameState.Get().mRoundClues[entry.speaker.PersonId]; string message; if (clueInfo != null) { Sentence newInfo = clueInfo.GetSentence(); message = "I found out " + entry.speaker.Speak(newInfo); // TODO: Announce the room where it was found if (newInfo.Subject.Type() == NounType.Unique) { message = "I found " + entry.speaker.Speak(newInfo); // TODO: Announce the room where it was found } ShareInfo(entry.speaker, newInfo); PlayerJournal.AddListen(entry.speaker.PersonId, newInfo); } else { message = "I found nothing."; } UIController.Get().ShowMessage(entry.speaker, entry.sprites, message, new string[] { "Continue" }, new UIButtonCallback[] { buttonIndex => Continue() }); } } else if (entry.isCustomSentence) { UIController.Get().AskForSentence(new Sprite[] { }, sentence => { if (entry.customSentenceCallback != null) { entry.customSentenceCallback(sentence); } Continue(); }, entry.subjectOverrides, entry.objectOverrides); } else // a regular message, just show it { UIController.Get().ShowMessage(entry.speaker, entry.sprites, entry.message, new string[] { "Continue" }, new UIButtonCallback[] { buttonIndex => Continue() }); } }