Ver.0.3.0.33
This commit is contained in:
@@ -10,33 +10,12 @@ namespace AibisDream
|
||||
public class DialogController : Singleton<DialogController>
|
||||
{
|
||||
private DialogueRunner _dialogueRunner;
|
||||
private VariableStorageBehaviour _variableStorage;
|
||||
private LocalisedLineProvider _lineProvider;
|
||||
|
||||
# region controller状态标识
|
||||
|
||||
private bool _isTalking;
|
||||
|
||||
public bool IsTalking
|
||||
{
|
||||
set
|
||||
{
|
||||
if (_isTalking == value) return;
|
||||
|
||||
_isTalking = value;
|
||||
Debug.Log($"IsTalking 状态更改: {_isTalking}");
|
||||
if (value)
|
||||
{
|
||||
OnDialogueStart?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnDialogueComplete?.Invoke();
|
||||
}
|
||||
}
|
||||
get => _isTalking;
|
||||
}
|
||||
|
||||
public bool quickRunMode;
|
||||
public bool autoRunMode;
|
||||
|
||||
# endregion
|
||||
|
||||
@@ -46,71 +25,20 @@ namespace AibisDream
|
||||
private void Start()
|
||||
{
|
||||
_dialogueRunner = GetComponentInChildren<DialogueRunner>();
|
||||
_variableStorage = GetComponentInChildren<InMemoryVariableStorage>();
|
||||
_lineProvider = GetComponentInChildren<LocalisedLineProvider>();
|
||||
|
||||
_dialogueRunner.onDialogueStart.AddListener(() =>
|
||||
{
|
||||
EnumEventSystem.Global.Send(InteractionEventEnum.End);
|
||||
OnDialogueStart?.Invoke();
|
||||
IsTalking = true;
|
||||
});
|
||||
_dialogueRunner.onDialogueComplete.AddListener(() =>
|
||||
{
|
||||
EnumEventSystem.Global.Send(InteractionEventEnum.Start);
|
||||
OnDialogueComplete?.Invoke();
|
||||
IsTalking = false;
|
||||
});
|
||||
|
||||
RegisterEvent();
|
||||
}
|
||||
|
||||
private void RegisterEvent()
|
||||
{
|
||||
EnumEventSystem.Global.Register(EventEnum.SceneUnload, ResetDialog);
|
||||
}
|
||||
|
||||
private void ResetDialog()
|
||||
{
|
||||
_dialogueRunner.Stop();
|
||||
_variableStorage.Clear();
|
||||
DialogCanvasManager.Instance.HideDialog();
|
||||
DialogCanvasManager.Instance.SwitchDialogView(DialogViewType.OldBox);
|
||||
}
|
||||
|
||||
#region 变量操作
|
||||
|
||||
public bool TryGetVariable<T>(string variableName, out T result)
|
||||
{
|
||||
return _variableStorage.TryGetValue(variableName, out result);
|
||||
}
|
||||
|
||||
public void SetVariable(string variableName, string value)
|
||||
{
|
||||
_variableStorage.SetValue(variableName, value);
|
||||
}
|
||||
|
||||
public void SetVariable(string variableName, bool value)
|
||||
{
|
||||
_variableStorage.SetValue(variableName, value);
|
||||
}
|
||||
|
||||
public void SetVariable(string variableName, float value)
|
||||
{
|
||||
_variableStorage.SetValue(variableName, value);
|
||||
}
|
||||
|
||||
public bool Contains(string variableName)
|
||||
{
|
||||
return _variableStorage.Contains(variableName);
|
||||
}
|
||||
|
||||
public void ClearVariables()
|
||||
{
|
||||
_variableStorage.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 开启对话
|
||||
/// </summary>
|
||||
@@ -118,16 +46,27 @@ namespace AibisDream
|
||||
public void StartDialog(YarnProject yarnProject)
|
||||
{
|
||||
_dialogueRunner.SetProject(yarnProject);
|
||||
_lineProvider.InitStringTable(yarnProject.name);
|
||||
_dialogueRunner.StartDialogue("Start");
|
||||
}
|
||||
|
||||
public string GetCurLocalizedTableName()
|
||||
{
|
||||
return _lineProvider.GetStringTableName();
|
||||
}
|
||||
|
||||
public void StopDialog()
|
||||
{
|
||||
_dialogueRunner.Stop();
|
||||
StorageSystem.Instance.Clear();
|
||||
DialogCanvasManager.Instance.HideDialog();
|
||||
DialogCanvasManager.Instance.SwitchDialogView(DialogViewType.StandardBubble);
|
||||
}
|
||||
|
||||
public void LoadDialog(YarnProject yarnProject)
|
||||
{
|
||||
_dialogueRunner.SetProject(yarnProject);
|
||||
_lineProvider.InitStringTable(yarnProject.name);
|
||||
_dialogueRunner.StartDialogue("Center");
|
||||
}
|
||||
|
||||
@@ -139,7 +78,7 @@ namespace AibisDream
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckIfNodeExistInCurrentYarnProject(string nodeName)
|
||||
private bool CheckIfNodeExistInCurrentYarnProject(string nodeName)
|
||||
{
|
||||
YarnProject currentProject = _dialogueRunner.yarnProject;
|
||||
string[] nodeNames = currentProject.NodeNames;
|
||||
@@ -153,7 +92,7 @@ namespace AibisDream
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 跳到下一句
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user