52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
using System;
|
|
using AibisDream.Framework;
|
|
using AibisDream.Utility;
|
|
using Yarn.Unity;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class LineView : DialogueViewBase
|
|
{
|
|
public override void RunLine(LocalizedLine dialogueLine, Action onDialogueLineFinished)
|
|
{
|
|
EnumEventSystem.Global.Send(DialogEventEnum.LineStart, DialogText.GetLine(dialogueLine));
|
|
|
|
Action jumpVoice = SkipVoice;
|
|
HandleLineOutput(dialogueLine, jumpVoice, onDialogueLineFinished);
|
|
HandleVoiceOutput(dialogueLine);
|
|
|
|
if (DialogController.Instance.quickRunMode)
|
|
{
|
|
onDialogueLineFinished.Invoke();
|
|
}
|
|
}
|
|
|
|
private void HandleLineOutput(LocalizedLine dialogueLine, Action onTextShowed, Action onDialogueLineFinished)
|
|
{
|
|
DialogCanvasManager.Instance.ShowLine(dialogueLine.TextWithoutCharacterName.Text,
|
|
dialogueLine.GetCharacterVo(), onDialogueLineFinished, onTextShowed, dialogueLine.IsAutoSkipLine());
|
|
}
|
|
|
|
private void HandleVoiceOutput(LocalizedLine dialogueLine)
|
|
{
|
|
// 播放语音
|
|
var voicePath = dialogueLine.GetCharacterVo().voicePath;
|
|
if (!string.IsNullOrWhiteSpace(voicePath))
|
|
{
|
|
AudioManager.Instance.RandomPlayVoice(voicePath);
|
|
}
|
|
}
|
|
|
|
private void SkipVoice()
|
|
{
|
|
AudioManager.Instance.StopVoice();
|
|
}
|
|
|
|
public override void RunOptions(DialogueOption[] dialogueOptions, Action<int> onOptionSelected)
|
|
{
|
|
EnumEventSystem.Global.Send(DialogEventEnum.OptionShow);
|
|
var options = DialogOption.GeneOptions(dialogueOptions, onOptionSelected);
|
|
DialogCanvasManager.Instance.ShowOptions(options);
|
|
}
|
|
}
|
|
} |