存档读档功能
This commit is contained in:
@@ -10,10 +10,10 @@ namespace AibisDream
|
||||
{
|
||||
public class DialogController : Singleton<DialogController>
|
||||
{
|
||||
private DialogueRunner dialogueRunner;
|
||||
private DialogueRunner _dialogueRunner;
|
||||
private VariableStorageBehaviour _variableStorage;
|
||||
|
||||
private readonly Dictionary<string, Action<YarnOption[]>> commandMap = new();
|
||||
private readonly Dictionary<string, Action<YarnOption[]>> _commandMap = new();
|
||||
private readonly Dictionary<string, Action<YarnContinueStep>> _pauseCommandMap = new();
|
||||
|
||||
# region controller状态标识
|
||||
@@ -37,7 +37,7 @@ namespace AibisDream
|
||||
OnDialogueComplete?.Invoke();
|
||||
}
|
||||
}
|
||||
get { return _isTalking; }
|
||||
get => _isTalking;
|
||||
}
|
||||
|
||||
// 对话框被阻塞时不能继续对话框交互
|
||||
@@ -45,9 +45,6 @@ namespace AibisDream
|
||||
|
||||
public bool quickRunMode;
|
||||
|
||||
// 暂停对话
|
||||
public bool isInPause;
|
||||
|
||||
# endregion
|
||||
|
||||
public static UnityAction OnDialogueStart;
|
||||
@@ -55,15 +52,15 @@ namespace AibisDream
|
||||
|
||||
private void Start()
|
||||
{
|
||||
dialogueRunner = GetComponentInChildren<DialogueRunner>();
|
||||
_dialogueRunner = GetComponentInChildren<DialogueRunner>();
|
||||
_variableStorage = GetComponentInChildren<InMemoryVariableStorage>();
|
||||
|
||||
dialogueRunner.onDialogueStart.AddListener(() =>
|
||||
_dialogueRunner.onDialogueStart.AddListener(() =>
|
||||
{
|
||||
OnDialogueStart?.Invoke();
|
||||
IsTalking = true;
|
||||
});
|
||||
dialogueRunner.onDialogueComplete.AddListener(() =>
|
||||
_dialogueRunner.onDialogueComplete.AddListener(() =>
|
||||
{
|
||||
OnDialogueComplete?.Invoke();
|
||||
IsTalking = false;
|
||||
@@ -110,22 +107,27 @@ namespace AibisDream
|
||||
/// <param name="yarnProject">Yarn组</param>
|
||||
public void StartDialog(YarnProject yarnProject)
|
||||
{
|
||||
dialogueRunner.VariableStorage.Clear();
|
||||
dialogueRunner.SetProject(yarnProject);
|
||||
dialogueRunner.StartDialogue("Start");
|
||||
_dialogueRunner.SetProject(yarnProject);
|
||||
_dialogueRunner.StartDialogue("Start");
|
||||
}
|
||||
|
||||
public void LoadDialog(YarnProject yarnProject)
|
||||
{
|
||||
_dialogueRunner.SetProject(yarnProject);
|
||||
_dialogueRunner.StartDialogue("主维修界面");
|
||||
}
|
||||
|
||||
public void StartDialogNode(string nodeName)
|
||||
{
|
||||
if (CheckIfNodeExistInCurrentYarnProject(nodeName))
|
||||
{
|
||||
dialogueRunner.StartDialogue(nodeName);
|
||||
_dialogueRunner.StartDialogue(nodeName);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckIfNodeExistInCurrentYarnProject(string nodeName)
|
||||
{
|
||||
YarnProject currentProject = dialogueRunner.yarnProject;
|
||||
YarnProject currentProject = _dialogueRunner.yarnProject;
|
||||
string[] nodeNames = currentProject.NodeNames;
|
||||
if (Array.Exists(nodeNames, item => item == nodeName))
|
||||
{
|
||||
@@ -153,7 +155,7 @@ namespace AibisDream
|
||||
return;
|
||||
}
|
||||
|
||||
if (commandMap.TryGetValue(commandName, out var action))
|
||||
if (_commandMap.TryGetValue(commandName, out var action))
|
||||
{
|
||||
action(options);
|
||||
}
|
||||
@@ -170,12 +172,12 @@ namespace AibisDream
|
||||
/// <param name="commandAction">注册名称</param>
|
||||
public void RegisterOptionCommand(string commandName, Action<YarnOption[]> commandAction)
|
||||
{
|
||||
if (commandMap.ContainsKey(commandName))
|
||||
if (_commandMap.ContainsKey(commandName))
|
||||
{
|
||||
Debug.Log($"命令 {commandName} 已经存在,将被替换");
|
||||
}
|
||||
|
||||
commandMap[commandName] = commandAction;
|
||||
_commandMap[commandName] = commandAction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -184,9 +186,9 @@ namespace AibisDream
|
||||
/// <param name="commandName">命令名称</param>
|
||||
public void RemoveOptionCommand(string commandName)
|
||||
{
|
||||
if (commandMap.ContainsKey(commandName))
|
||||
if (_commandMap.ContainsKey(commandName))
|
||||
{
|
||||
commandMap.Remove(commandName);
|
||||
_commandMap.Remove(commandName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -260,7 +262,8 @@ namespace AibisDream
|
||||
[YarnCommand("NextYarn")]
|
||||
public static void NextYarn()
|
||||
{
|
||||
DialogController.Instance.StartCoroutine(GameLoopManager.Instance.NextSceneSo());
|
||||
Instance.ClearVariables();
|
||||
Instance.StartCoroutine(GameLoopManager.Instance.NextSceneSo());
|
||||
}
|
||||
|
||||
[YarnCommand("switch_tv")]
|
||||
|
||||
Reference in New Issue
Block a user