气泡组件和配置项
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using AibisDream.Utility;
|
||||
using Yarn.Unity;
|
||||
|
||||
namespace AibisDream
|
||||
@@ -6,24 +7,24 @@ namespace AibisDream
|
||||
public class CommandOptionView : DialogueViewBase
|
||||
{
|
||||
// 进入指令选项模式
|
||||
private bool isInCommand;
|
||||
private string commandName;
|
||||
private bool _isInCommand;
|
||||
private string _commandName;
|
||||
|
||||
public override void RunLine(LocalizedLine dialogueLine, Action onDialogueLineFinished)
|
||||
{
|
||||
// 判断选项选项行
|
||||
if (dialogueLine.Text.IsOptionAttrLine())
|
||||
{
|
||||
isInCommand = true;
|
||||
_isInCommand = true;
|
||||
base.RunLine(dialogueLine, onDialogueLineFinished);
|
||||
return;
|
||||
}
|
||||
// 判断是否进入Command状态
|
||||
isInCommand = dialogueLine.Text.TryGetCommandAttr(out var curCommandName);
|
||||
if (isInCommand)
|
||||
_isInCommand = dialogueLine.Text.TryGetCommandAttr(out var curCommandName);
|
||||
if (_isInCommand)
|
||||
{
|
||||
// 保存指令
|
||||
commandName = curCommandName;
|
||||
_commandName = curCommandName;
|
||||
// 进入下一步
|
||||
onDialogueLineFinished.Invoke();
|
||||
}
|
||||
@@ -36,7 +37,7 @@ namespace AibisDream
|
||||
public override void RunOptions(DialogueOption[] dialogueOptions, Action<int> onOptionSelected)
|
||||
{
|
||||
// 非指令直接跳过
|
||||
if (!isInCommand)
|
||||
if (!_isInCommand)
|
||||
{
|
||||
base.RunOptions(dialogueOptions, onOptionSelected);
|
||||
return;
|
||||
@@ -45,7 +46,7 @@ namespace AibisDream
|
||||
DialogController.Instance.IsTalking = false;
|
||||
// 传输选项
|
||||
YarnOption[] options = YarnOption.GeneOptions(dialogueOptions, onOptionSelected);
|
||||
DialogController.Instance.InvokeOptionCommand(commandName, options);
|
||||
DialogController.Instance.InvokeOptionCommand(_commandName, options);
|
||||
}
|
||||
|
||||
public override void InterruptLine(LocalizedLine dialogueLine, Action onDialogueLineFinished)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using AibisDream.Utility;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using Yarn.Unity;
|
||||
@@ -11,12 +12,13 @@ namespace AibisDream
|
||||
public class DialogController : Singleton<DialogController>
|
||||
{
|
||||
private const string BookManager = "BookManager";
|
||||
|
||||
private DialogueRunner dialogueRunner;
|
||||
|
||||
private DialogueRunner dialogueRunner;
|
||||
private VariableStorageBehaviour _variableStorage;
|
||||
|
||||
private Dictionary<string, Action<YarnOption[]>> commandMap = new();
|
||||
private readonly Dictionary<string, Action<YarnOption[]>> commandMap = new();
|
||||
|
||||
# region controller状态标识
|
||||
|
||||
private bool _isTalking;
|
||||
|
||||
@@ -39,13 +41,15 @@ namespace AibisDream
|
||||
}
|
||||
|
||||
// 对话框被阻塞时不能继续对话框交互
|
||||
public bool IsBlock { get; set; }
|
||||
public bool IsBlock { get; private set; }
|
||||
|
||||
public bool quickRunMode;
|
||||
|
||||
# endregion
|
||||
|
||||
public static UnityAction OnDialogueStart;
|
||||
public static UnityAction OnDialogueComplete;
|
||||
|
||||
public bool quickRunMode;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
dialogueRunner = GetComponentInChildren<DialogueRunner>();
|
||||
@@ -63,6 +67,7 @@ namespace AibisDream
|
||||
// 对话结束时切下一个SO
|
||||
dialogueRunner.onDialogueComplete.AddListener(() =>
|
||||
{
|
||||
DialogCanvasManager.Instance.SwitchDialogView(DialogViewType.Bubble);
|
||||
StartCoroutine(GameLoopManager.Instance.NextSceneSo());
|
||||
});
|
||||
}
|
||||
@@ -97,6 +102,7 @@ namespace AibisDream
|
||||
/// <param name="yarnProject">Yarn组</param>
|
||||
public void StartDialog(YarnProject yarnProject)
|
||||
{
|
||||
dialogueRunner.VariableStorage.Clear();
|
||||
dialogueRunner.SetProject(yarnProject);
|
||||
dialogueRunner.StartDialogue("Start");
|
||||
}
|
||||
@@ -135,7 +141,7 @@ namespace AibisDream
|
||||
{
|
||||
Debug.Log($"命令 {commandName} 已经存在,将被替换");
|
||||
}
|
||||
|
||||
|
||||
commandMap[commandName] = commandAction;
|
||||
}
|
||||
|
||||
@@ -210,11 +216,12 @@ namespace AibisDream
|
||||
{
|
||||
HideDialog();
|
||||
//yield return MainUIController.Instance.FadeInSync(duration);
|
||||
Camera.main.orthographicSize=5;
|
||||
Camera.main.transform.position=new Vector3(0,0,-10);
|
||||
Camera.main.orthographicSize = 5;
|
||||
Camera.main.transform.position = new Vector3(0, 0, -10);
|
||||
yield return SceneLoader.Instance.LoadSceneAsync(sceneName);
|
||||
//yield return new WaitForSeconds(1f);
|
||||
//yield return MainUIController.Instance.FadeOutSync(duration);
|
||||
DialogCanvasManager.Instance.SwitchDialogView(sceneName == "ClinicScene"
|
||||
? DialogViewType.Bubble
|
||||
: DialogViewType.OldBox);
|
||||
}
|
||||
|
||||
[YarnCommand("unload_scene")]
|
||||
@@ -226,7 +233,7 @@ namespace AibisDream
|
||||
[YarnCommand("hide_dialog")]
|
||||
public static void HideDialog()
|
||||
{
|
||||
DialogUiViewer.Instance.HideDialog();
|
||||
DialogCanvasManager.GetCurView().HideDialog();
|
||||
}
|
||||
|
||||
[YarnCommand("fade_in")]
|
||||
@@ -246,24 +253,25 @@ namespace AibisDream
|
||||
{
|
||||
return MainUIController.Instance.ShowObj(picName);
|
||||
}
|
||||
|
||||
|
||||
[YarnCommand("hide_obj")]
|
||||
public static IEnumerator HideObj()
|
||||
{
|
||||
return MainUIController.Instance.HideObj();
|
||||
}
|
||||
|
||||
[YarnCommand("move_to_fix")]
|
||||
public static IEnumerator Move_to_fix()
|
||||
public static IEnumerator MoveToFix()
|
||||
{
|
||||
bool isCompleted = false;
|
||||
Sequence s = DOTween.Sequence();
|
||||
s.Append(Camera.main.transform.DOMove(new UnityEngine.Vector3(6.8f, 0, -10), 2f))
|
||||
.OnComplete(() =>
|
||||
{
|
||||
// 动画完成后的反馈操作
|
||||
Debug.Log("Move_to_fix sequence completed.");
|
||||
isCompleted = true;
|
||||
});
|
||||
.OnComplete(() =>
|
||||
{
|
||||
// 动画完成后的反馈操作
|
||||
Debug.Log("Move_to_fix sequence completed.");
|
||||
isCompleted = true;
|
||||
});
|
||||
|
||||
// 等待动画完成
|
||||
yield return new WaitUntil(() => isCompleted);
|
||||
@@ -271,15 +279,22 @@ namespace AibisDream
|
||||
// 动画完成后的其他操作
|
||||
Debug.Log("Continuing after Move_to_fix sequence.");
|
||||
}
|
||||
|
||||
[YarnCommand("move_out_fix")]
|
||||
public static void Move_out_fix()
|
||||
public static void MoveOutFix()
|
||||
{
|
||||
Camera.main.transform.position=new UnityEngine.Vector3(6.8f, 0, -10);
|
||||
Camera.main.transform.position = new UnityEngine.Vector3(6.8f, 0, -10);
|
||||
Sequence s = DOTween.Sequence();
|
||||
//s.AppendInterval(0.5f);
|
||||
s.Append(Camera.main.transform.DOMove(new UnityEngine.Vector3(0, 0, -10), 2f));
|
||||
}
|
||||
|
||||
|
||||
[YarnCommand("switch_dialog_view")]
|
||||
public static void SwitchDialogView(string viewName)
|
||||
{
|
||||
DialogCanvasManager.Instance.SwitchDialogView(Enum.Parse<DialogViewType>(viewName));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using AibisDream.Utility;
|
||||
using Yarn.Unity;
|
||||
|
||||
namespace AibisDream
|
||||
{
|
||||
public class LineView : DialogueViewBase
|
||||
{
|
||||
private const string AutoNext = "auto_next";
|
||||
|
||||
// 进入指令选项模式
|
||||
private bool _isInCommand;
|
||||
|
||||
@@ -17,11 +15,11 @@ namespace AibisDream
|
||||
|
||||
if (_isInCommand)
|
||||
{
|
||||
DialogUiViewer.Instance.HideDialog();
|
||||
DialogCanvasManager.GetCurView().HideDialog();
|
||||
base.RunLine(dialogueLine, onDialogueLineFinished);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
HandleLineOutput(dialogueLine, onDialogueLineFinished);
|
||||
|
||||
if (DialogController.Instance.quickRunMode)
|
||||
@@ -35,32 +33,21 @@ namespace AibisDream
|
||||
// 对话系统正在交谈状态
|
||||
DialogController.Instance.IsTalking = true;
|
||||
|
||||
// 解析LocalizedLine
|
||||
if (dialogueLine.Metadata != null && dialogueLine.Metadata.Contains(AutoNext))
|
||||
{
|
||||
// 自动跳过
|
||||
DialogUiViewer.Instance.ShowAutoLine(dialogueLine.TextWithoutCharacterName.Text,
|
||||
dialogueLine.CharacterName, onDialogueLineFinished);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 需要玩家点击
|
||||
DialogUiViewer.Instance.ShowLine(dialogueLine.TextWithoutCharacterName.Text,
|
||||
dialogueLine.CharacterName, onDialogueLineFinished);
|
||||
}
|
||||
DialogCanvasManager.GetCurView().ShowLine(dialogueLine.TextWithoutCharacterName.Text,
|
||||
dialogueLine.GetCharacterVo(), onDialogueLineFinished, dialogueLine.IsAutoSkipLine());
|
||||
}
|
||||
|
||||
public override void RunOptions(DialogueOption[] dialogueOptions, Action<int> onOptionSelected)
|
||||
{
|
||||
if (_isInCommand)
|
||||
{
|
||||
DialogUiViewer.Instance.HideDialog();
|
||||
DialogCanvasManager.GetCurView().HideDialog();
|
||||
base.RunOptions(dialogueOptions, onOptionSelected);
|
||||
return;
|
||||
}
|
||||
|
||||
DialogController.Instance.IsTalking = true;
|
||||
DialogUiViewer.Instance.ShowOptions(dialogueOptions, onOptionSelected);
|
||||
DialogCanvasManager.GetCurView().ShowOptions(dialogueOptions, onOptionSelected);
|
||||
}
|
||||
|
||||
public override void InterruptLine(LocalizedLine dialogueLine, Action onDialogueLineFinished)
|
||||
@@ -84,13 +71,11 @@ namespace AibisDream
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DialogUiViewer.Instance.TrySkipLine())
|
||||
|
||||
if (!DialogCanvasManager.GetCurView().TrySkipLine())
|
||||
{
|
||||
DialogUiViewer.Instance.AfterEndLine();
|
||||
requestInterrupt.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user