protected virtual void DoAlertAction() { if (string.IsNullOrEmpty(alertMessage)) { return; } string localizedAlertMessage; if ((textTable != null) && textTable.HasFieldTextForLanguage(alertMessage, Localization.GetCurrentLanguageID(textTable))) { localizedAlertMessage = textTable.GetFieldTextForLanguage(alertMessage, Localization.GetCurrentLanguageID(textTable)); } else { localizedAlertMessage = DialogueManager.GetLocalizedText(alertMessage); } if (Mathf.Approximately(0, alertDuration)) { DialogueManager.ShowAlert(localizedAlertMessage); } else { DialogueManager.ShowAlert(localizedAlertMessage, alertDuration); } }
/// <summary> /// If useDefaultGUI is <c>true</c> and a usable object has been targeted, this method /// draws a selection message and targeting reticle. /// </summary> public virtual void OnGUI() { if (!useDefaultGUI) { return; } if (guiStyle == null && (Event.current.type == EventType.Repaint || usable != null)) { SetGuiStyle(); } if (usable != null) { bool inUseRange = (distance <= usable.maxUseDistance); guiStyle.normal.textColor = inUseRange ? inRangeColor : outOfRangeColor; if (string.IsNullOrEmpty(heading)) { heading = usable.GetName(); useMessage = DialogueManager.GetLocalizedText(string.IsNullOrEmpty(usable.overrideUseMessage) ? defaultUseMessage : usable.overrideUseMessage); } UnityGUITools.DrawText(new Rect(0, 0, Screen.width, Screen.height), heading, guiStyle, textStyle, textStyleColor); UnityGUITools.DrawText(new Rect(0, guiStyleLineHeight, Screen.width, Screen.height), useMessage, guiStyle, textStyle, textStyleColor); Texture2D reticleTexture = inUseRange ? reticle.inRange : reticle.outOfRange; if (reticleTexture != null) { GUI.Label(new Rect(0.5f * (Screen.width - reticle.width), 0.5f * (Screen.height - reticle.height), reticle.width, reticle.height), reticleTexture); } } }
/// <summary> /// Gets the localized text for a field name. /// </summary> /// <returns>The localized text.</returns> /// <param name="fieldName">Field name.</param> public virtual string GetLocalizedText(string fieldName) { if ((textTable != null) && textTable.HasFieldTextForLanguage(fieldName, Localization.GetCurrentLanguageID(textTable))) { return(textTable.GetFieldTextForLanguage(fieldName, Localization.GetCurrentLanguageID(textTable))); } else { return(DialogueManager.GetLocalizedText(fieldName)); } }
/// <summary> /// Call this method to manually run the action. /// </summary> public void Fire() { // Quest: if (!string.IsNullOrEmpty(questName)) { QuestLog.SetQuestState(questName, questState); } // Lua: if (!string.IsNullOrEmpty(luaCode)) { Lua.Run(luaCode, DialogueDebug.logInfo); DialogueManager.CheckAlerts(); } // Sequence: if (!string.IsNullOrEmpty(sequence)) { DialogueManager.PlaySequence(sequence); } // Alert: if (!string.IsNullOrEmpty(alertMessage)) { string localizedAlertMessage; if ((textTable != null) && textTable.HasFieldTextForLanguage(alertMessage, Localization.GetCurrentLanguageID(textTable))) { localizedAlertMessage = textTable.GetFieldTextForLanguage(alertMessage, Localization.GetCurrentLanguageID(textTable)); } else { localizedAlertMessage = DialogueManager.GetLocalizedText(alertMessage); } DialogueManager.ShowAlert(localizedAlertMessage); } // Send Messages: foreach (var sma in sendMessages) { if (sma.gameObject != null && !string.IsNullOrEmpty(sma.message)) { sma.gameObject.SendMessage(sma.message, sma.parameter, SendMessageOptions.DontRequireReceiver); } } DialogueManager.SendUpdateTracker(); if (once) { StopObserving(); enabled = false; } }
protected virtual void SetCurrentUsable(Usable usable) { currentUsable = usable; if (usable != null) { currentHeading = currentUsable.GetName(); currentUseMessage = DialogueManager.GetLocalizedText(string.IsNullOrEmpty(currentUsable.overrideUseMessage) ? defaultUseMessage : currentUsable.overrideUseMessage); } else { currentHeading = string.Empty; currentUseMessage = string.Empty; } }
/// <summary> /// Gets the name of the override, including parsing if it contains a [lua] /// or [var] tag. /// </summary> /// <returns>The override name.</returns> public string GetName() { if (string.IsNullOrEmpty(overrideName)) { return(name); } else if (overrideName.Contains("[lua") || overrideName.Contains("[var")) { return(DialogueManager.GetLocalizedText(FormattedText.Parse(overrideName, DialogueManager.masterDatabase.emphasisSettings).text)); } else { return(DialogueManager.GetLocalizedText(overrideName)); } }
public override void Show(string useMessage) { if (canvas != null) { canvas.enabled = true; } if (useMessageText != null) { useMessageText.text = DialogueManager.GetLocalizedText(useMessage); } if (CanTriggerAnimations() && !string.IsNullOrEmpty(animationTransitions.showTrigger)) { animator.SetTrigger(animationTransitions.showTrigger); } }
private string GetUseMessage() { return(DialogueManager.GetLocalizedText(string.IsNullOrEmpty(usable.overrideUseMessage) ? defaultUseMessage : usable.overrideUseMessage)); }