/// <summary> /// Initializes a new ConversationState. /// </summary> /// <param name='subtitle'> /// Subtitle of the current dialogue entry. /// </param> /// <param name='npcResponses'> /// NPC responses. /// </param> /// <param name='pcResponses'> /// PC responses. /// </param> public ConversationState(Subtitle subtitle, Response[] npcResponses, Response[] pcResponses, bool isGroup = false) { this.subtitle = subtitle; this.npcResponses = npcResponses; this.pcResponses = pcResponses; this.IsGroup = isGroup; }
/// <summary> /// Shows the subtitle reminder and response buttons. /// </summary> /// <param name='subtitle'> /// Subtitle reminder. /// </param> /// <param name='responses'> /// Responses. /// </param> /// <param name='target'> /// Target that will receive OnClick events from the buttons. /// </param> public void ShowResponses(Subtitle subtitle, Response[] responses, Transform target) { if ((responses != null) && (responses.Length > 0)) { SubtitleReminder.ShowSubtitle(subtitle); ClearResponseButtons(); SetResponseButtons(responses, target); Show(); } else { Hide(); } }
private void SetResponseButton(UnityUIResponseButton button, Response response, Transform target) { if (button != null) { button.visible = true; button.clickable = response.enabled; button.target = target; if (response != null) button.SetFormattedText(response.formattedText); button.response = response; } }
/// <summary> /// Sets the response buttons. /// </summary> /// <param name='responses'> /// Responses. /// </param> /// <param name='target'> /// Target that will receive OnClick events from the buttons. /// </param> protected override void SetResponseButtons(Response[] responses, Transform target) { DestroyInstantiatedButtons(); if ((buttons != null) && (responses != null)) { // Add explicitly-positioned buttons: for (int i = 0; i < responses.Length; i++) { if (responses[i].formattedText.position != FormattedText.NoAssignedPosition) { int position = Mathf.Clamp(responses[i].formattedText.position, 0, buttons.Length - 1); SetResponseButton(buttons[position], responses[i], target); } } if ((buttonTemplate != null) && (buttonTemplateHolder != null)) { // Reset scrollbar to top: if (buttonTemplateScrollbar != null) { buttonTemplateScrollbar.value = buttonTemplateScrollbarResetValue; } // Instantiate buttons from template: for (int i = 0; i < responses.Length; i++) { GameObject buttonGameObject = GameObject.Instantiate(buttonTemplate.gameObject) as GameObject; if (buttonGameObject == null) { Debug.LogError(string.Format("{0}: Couldn't instantiate response button template", DialogueDebug.Prefix)); } else { instantiatedButtons.Add(buttonGameObject); buttonGameObject.transform.SetParent(buttonTemplateHolder.transform, false); buttonGameObject.SetActive(true); UnityUIResponseButton responseButton = buttonGameObject.GetComponent<UnityUIResponseButton>(); SetResponseButton(responseButton, responses[i], target); } } } else { // Auto-position remaining buttons: if (buttonAlignment == ResponseButtonAlignment.ToFirst) { // Align to first, so add in order to front: for (int i = 0; i < Mathf.Min(buttons.Length, responses.Length); i++) { if (responses[i].formattedText.position == FormattedText.NoAssignedPosition) { int position = Mathf.Clamp(GetNextAvailableResponseButtonPosition(0, 1), 0, buttons.Length - 1); SetResponseButton(buttons[position], responses[i], target); } } } else { // Align to last, so add in reverse order to back: for (int i = Mathf.Min(buttons.Length, responses.Length) - 1; i >= 0; i--) { if (responses[i].formattedText.position == FormattedText.NoAssignedPosition) { int position = Mathf.Clamp(GetNextAvailableResponseButtonPosition(buttons.Length - 1, -1), 0, buttons.Length - 1); SetResponseButton(buttons[position], responses[i], target); } } } } } NotifyContentChanged(); }
private void SetResponseButton(UnityUIResponseButton button, Response response, Transform target, int buttonNumber) { if (button != null) { button.visible = true; button.clickable = response.enabled; button.target = target; if (response != null) button.SetFormattedText(response.formattedText); button.response = response; // Auto-number: if (autonumber.enabled) { button.Text = string.Format(autonumber.format, buttonNumber + 1, button.Text); var keyTrigger = button.GetComponent<UIButtonKeyTrigger>(); if (keyTrigger == null) keyTrigger = button.gameObject.AddComponent<UIButtonKeyTrigger>(); keyTrigger.key = (KeyCode) ((int) KeyCode.Alpha1 + buttonNumber); } } }
private bool IsValidRuntimeResponse(Link link, Response[] responses) { foreach (var response in responses) { if ((link.destinationConversationID == response.destinationEntry.conversationID) && (link.destinationDialogueID == response.destinationEntry.id)) { return true; } } return false; }
public override void ShowResponses(Subtitle subtitle, Response[] responses, float timeout) { base.ShowResponses (subtitle, responses, timeout); CheckResponseMenuAutoFocus (); }
public void ShowResponses(Subtitle subtitle, Response[] responses, float timeout) { if (responses.Length > 0) { SelectedResponseHandler(this, new SelectedResponseEventArgs(responses[0])); } }
public override void ShowResponses (Subtitle subtitle, Response[] responses, float timeout) { if (findActorOverrides) { // Use speaker's (NPC's) world space canvas for subtitle reminder, and for menu if set: var overrideControls = FindActorOverride(subtitle.speakerInfo.transform); var subtitleReminder = (overrideControls != null) ? overrideControls.subtitleReminder : originalResponseMenu.subtitleReminder; if (overrideControls != null && overrideControls.responseMenu.panel != null) { dialogue.responseMenu = (overrideControls != null && overrideControls.responseMenu.panel != null) ? overrideControls.responseMenu : originalResponseMenu; } else { // Otherwise use PC's world space canvas for menu if set: overrideControls = FindActorOverride(subtitle.listenerInfo.transform); dialogue.responseMenu = (overrideControls != null && overrideControls.responseMenu.panel != null) ? overrideControls.responseMenu : originalResponseMenu; } // Either way, use speaker's (NPC's) subtitle reminder: dialogue.responseMenu.subtitleReminder = subtitleReminder; } base.ShowResponses(subtitle, responses, timeout); CheckResponseMenuAutoFocus(); }
private void NotifyOnResponseMenu(Response[] responses) { if (responses != null) { DialogueManager.Instance.BroadcastMessage ("OnConversationResponseMenu", responses, SendMessageOptions.DontRequireReceiver); } }
/// <summary> /// Displays the player response menu. /// </summary> /// <param name='subtitle'> /// Last subtitle, to display as a reminder of what the player is responding to. /// </param> /// <param name='responses'> /// Responses. /// </param> public void StartResponses(Subtitle subtitle, Response[] responses) { PlayResponseMenuSequence (subtitle.responseMenuSequence); Subtitle lastSubtitle = ShouldShowLastPCSubtitle () ? lastPCSubtitle : ShouldShowLastNPCSubtitle () ? lastNPCSubtitle : null; NotifyOnResponseMenu (responses); ui.ShowResponses (lastSubtitle, responses, settings.inputSettings.responseTimeout); IsCancelKeyDown = IsConversationCancelKeyDown; CancelledHandler = OnCancelResponseMenu; }
/// <summary> /// Shows the player responses menu. /// </summary> /// <param name='subtitle'> /// The last subtitle, shown as a reminder. /// </param> /// <param name='responses'> /// Responses. /// </param> /// <param name='timeout'> /// If not <c>0</c>, the duration in seconds that the player has to choose a response; /// otherwise the currently-focused response is auto-selected. If no response is /// focused (e.g., hovered over), the first response is auto-selected. If <c>0</c>, /// there is no timeout; the player can take as long as desired to choose a response. /// </param> public virtual void ShowResponses(Subtitle subtitle, Response[] responses, float timeout) { try { if (Dialogue == null) { Debug.LogError(DialogueDebug.Prefix + ": In ShowResponses(): The dialogue UI's main dialogue controls field is not set.", this); } else if (Dialogue.ResponseMenu == null) { Debug.LogError(DialogueDebug.Prefix + ": In ShowResponses(): The dialogue UI's response menu controls field is not set.", this); } else if (this.transform == null) { Debug.LogError(DialogueDebug.Prefix + ": In ShowResponses(): The dialogue UI's transform is null.", this); } else { Dialogue.ResponseMenu.ShowResponses(subtitle, responses, this.transform); if (timeout > 0) Dialogue.ResponseMenu.StartTimer(timeout); } } catch (NullReferenceException e) { Debug.LogError(DialogueDebug.Prefix + ": In ShowResponses(): " + e.Message); } }
/// <summary> /// Sets the response buttons. /// </summary> /// <param name='responses'> /// Responses. /// </param> /// <param name='target'> /// Target that will receive OnClick events from the buttons. /// </param> protected abstract void SetResponseButtons(Response[] responses, Transform target);
/// <summary> /// Initializes a new ResponseSelectedEventArgs. /// </summary> /// <param name='response'> /// The response. /// </param> public SelectedResponseEventArgs(Response response) { this.response = response; }
/// <summary> /// When showing the response menu, update the subtitle reminder image with /// the last speaker's animated portrait animator controller. /// </summary> /// <param name="responses">Responses.</param> public void OnConversationResponseMenu(Response[] responses) { if (!FindDialogueUI()) return; SetAnimatorController(dialogueUI.dialogue.responseMenu.subtitleReminder.portraitImage, lastSpeaker, ref npcReminderPortraitAnimator); }
public override void ShowResponses(Subtitle subtitle, Response[] responses, float timeout) { base.ShowResponses(subtitle, responses, timeout); if (autoFocus) dialogue.responseMenu.AutoFocus(); }
public override void ShowResponses(Subtitle subtitle, Response[] responses, float timeout) { Dialogue.PCSubtitle.Hide(); // Hide PC subtitle before showing PC response menu. base.ShowResponses(subtitle, responses, timeout); }