/// <summary> /// Show the alert if the condition is true. /// </summary> public void TryStart(Transform actor) { if (tryingToStart) { return; } tryingToStart = true; try { if (((condition == null) || condition.IsTrue(actor)) && !string.IsNullOrEmpty(message)) { string actualMessage = message; if ((localizedTextTable != null) && localizedTextTable.ContainsField(message)) { actualMessage = localizedTextTable[message]; } string text = FormattedText.Parse(actualMessage, DialogueManager.masterDatabase.emphasisSettings).text; if (Mathf.Approximately(0, duration)) { DialogueManager.ShowAlert(text); } else { DialogueManager.ShowAlert(text, duration); } DestroyIfOnce(); } } finally { tryingToStart = false; } }
public void LocalizeText() { if (!started) { return; } if (string.IsNullOrEmpty(PixelCrushers.DialogueSystem.Localization.Language)) { return; } if (text == null) { text = GetComponent <Text>(); } if (string.IsNullOrEmpty(fieldName)) { fieldName = (text != null) ? text.text : string.Empty; } if (localizedTextTable == null) { localizedTextTable = DialogueManager.DisplaySettings.localizationSettings.localizedText; } if (text == null) { if (DialogueDebug.LogWarnings) { Debug.LogWarning(DialogueDebug.Prefix + ": LocalizeUILabel didn't find a Text component on " + name + ".", this); } } else if (localizedTextTable == null) { if (DialogueDebug.LogWarnings) { Debug.LogWarning(DialogueDebug.Prefix + ": No localized text table is assigned to " + name + " or the Dialogue Manager.", this); } } else if (!localizedTextTable.ContainsField(fieldName)) { if (DialogueDebug.LogWarnings) { Debug.LogWarning(DialogueDebug.Prefix + ": Localized text table '" + localizedTextTable.name + "' does not have a field: " + fieldName, this); } } else if (!HasCurrentLanguage()) { if (DialogueDebug.LogWarnings) { Debug.LogWarning(DialogueDebug.Prefix + "Localized text table '" + localizedTextTable + "' does not have a language '" + PixelCrushers.DialogueSystem.Localization.Language + "'", this); } } else { text.text = localizedTextTable[fieldName]; } }
/// <summary> /// Gets the localized text for a field name. /// </summary> /// <returns>The localized text.</returns> /// <param name="fieldName">Field name.</param> public string GetLocalizedText(string fieldName) { if ((localizedText != null) && localizedText.ContainsField(fieldName)) { return(localizedText[fieldName]); } else { return(fieldName); } }
public void Fire() { if (DialogueDebug.logInfo) { Debug.Log(string.Format("{0}: Setting quest '{1}' state to '{2}'", new System.Object[] { DialogueDebug.Prefix, questName, QuestLog.StateToString(questState) })); } // Quest states: if (!string.IsNullOrEmpty(questName)) { if (setQuestState) { QuestLog.SetQuestState(questName, questState); } if (setQuestEntryState) { QuestLog.SetQuestEntryState(questName, questEntryNumber, questEntryState); } } // Lua: if (!string.IsNullOrEmpty(luaCode)) { Lua.Run(luaCode, DialogueDebug.logInfo); } // Alert: if (!string.IsNullOrEmpty(alertMessage)) { string localizedAlertMessage = alertMessage; if ((localizedTextTable != null) && localizedTextTable.ContainsField(alertMessage)) { localizedAlertMessage = localizedTextTable[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(); // Once? DestroyIfOnce(); }
/// <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); } // Alert: if (!string.IsNullOrEmpty(alertMessage)) { string localizedAlertMessage = alertMessage; if ((localizedTextTable != null) && localizedTextTable.ContainsField(alertMessage)) { localizedAlertMessage = localizedTextTable[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); } } // Once? if (once) { Destroy(this.gameObject); } }
public virtual void LocalizeText() { if (!started) { return; } // Skip if no language set: if (string.IsNullOrEmpty(PixelCrushers.DialogueSystem.Localization.Language)) { return; } if (localizedTextTable == null) { localizedTextTable = DialogueManager.DisplaySettings.localizationSettings.localizedText; if (localizedTextTable == null) { if (DialogueDebug.LogWarnings) { Debug.LogWarning(DialogueDebug.Prefix + ": No localized text table is assigned to " + name + " or the Dialogue Manager.", this); } return; } } if (!HasCurrentLanguage()) { if (DialogueDebug.LogWarnings) { Debug.LogWarning(DialogueDebug.Prefix + "Localized text table '" + localizedTextTable + "' does not have a language '" + PixelCrushers.DialogueSystem.Localization.Language + "'", this); } return; } // Make sure we have a Text or Dropdown: if (text == null && dropdown == null) { text = GetComponent <UnityEngine.UI.Text>(); #if !(UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1) dropdown = GetComponent <UnityEngine.UI.Dropdown>(); #endif if (text == null && dropdown == null) { if (DialogueDebug.LogWarnings) { Debug.LogWarning(DialogueDebug.Prefix + ": LocalizeUIText didn't find a Text or Dropdown component on " + name + ".", this); } return; } } // Get the original values to use as field lookups: if (string.IsNullOrEmpty(fieldName)) { fieldName = (text != null) ? text.text : string.Empty; } #if !(UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1) if ((fieldNames.Count == 0) && (dropdown != null)) { dropdown.options.ForEach(opt => fieldNames.Add(opt.text)); } #endif // Localize Text: if (text != null) { if (!localizedTextTable.ContainsField(fieldName)) { if (DialogueDebug.LogWarnings) { Debug.LogWarning(DialogueDebug.Prefix + ": Localized text table '" + localizedTextTable.name + "' does not have a field: " + fieldName, this); } } else { text.text = localizedTextTable[fieldName]; } } #if !(UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1) // Localize Dropdown: if (dropdown != null) { for (int i = 0; i < dropdown.options.Count; i++) { if (i < fieldNames.Count) { dropdown.options[i].text = localizedTextTable[fieldNames[i]]; } } dropdown.captionText.text = localizedTextTable[fieldNames[dropdown.value]]; } #endif }