对话回顾

This commit is contained in:
2025-01-10 21:39:25 +08:00
parent 62cc381479
commit b7cb09439e
32 changed files with 1083 additions and 2146 deletions
+12 -21
View File
@@ -30,9 +30,10 @@ namespace AibisDream
#endregion
private bool _skipLineDelay;
[Header("跳过阻塞延迟时间/ms")]
[SerializeField] private int delayTime = 300;
[Header("跳过阻塞延迟时间/ms")] [SerializeField]
private int delayTime = 300;
protected GameObject choiceButtonPrefab;
protected virtual void Awake()
@@ -85,7 +86,8 @@ namespace AibisDream
/// <param name="nextStep">下一步</param>
/// <param name="onTextShowed">文字展示结束后触发</param>
/// <param name="isAutoSkip">是否自动跳过,默认为false</param>
public virtual void ShowLine(string dialogLine, CharacterVo character, Action nextStep, Action onTextShowed ,bool isAutoSkip = false)
public virtual void ShowLine(string dialogLine, CharacterVo character, Action nextStep, Action onTextShowed,
bool isAutoSkip = false)
{
gameObject.SetActive(true);
// 没有dialogText说明不能显示对话,直接跳过
@@ -122,7 +124,7 @@ namespace AibisDream
/// </summary>
/// <param name="dialogueOptions">对话选项</param>
/// <param name="onOptionSelected">选项选择</param>
public virtual void ShowOptions(DialogueOption[] dialogueOptions, Action<int> onOptionSelected)
public virtual void ShowOptions(DialogOption[] dialogueOptions)
{
gameObject.SetActive(true);
// 没有选择框直接不显示选项
@@ -143,15 +145,13 @@ namespace AibisDream
}
// 生成新按钮
foreach (DialogueOption option in dialogueOptions)
foreach (var option in dialogueOptions)
{
if (!option.IsAvailable) continue;
var choiceInstance = Instantiate(choiceButtonPrefab, choiceBox.transform);
choiceInstance.GetComponentInChildren<TextMeshProUGUI>().text =
option.Line.TextWithoutCharacterName.Text;
choiceInstance.GetComponent<Button>().onClick
.AddListener(() => onOptionSelected.Invoke(option.DialogueOptionID));
choiceInstance.GetComponentInChildren<TextMeshProUGUI>().text = option.Line;
choiceInstance.GetComponent<Button>().onClick.AddListener(option.Select);
}
}
@@ -167,7 +167,7 @@ namespace AibisDream
{
return true;
}
if (dialogText.isShowingText)
{
dialogText.SkipTypewriter();
@@ -191,16 +191,7 @@ namespace AibisDream
private void ShowActorName(CharacterVo character)
{
if (!actorName) return;
if (string.IsNullOrEmpty(character.nameColor))
{
actorName.text = character.cn;
}
else
{
var showStr = $"<color={character.nameColor}>{character.cn}</color>";
actorName.text = showStr;
}
actorName.text = character.GetActorName();
}
}
}