自动跳过和判断是否在对话的逻辑

This commit is contained in:
2024-08-29 00:05:25 +08:00
parent ef6aac8474
commit 144547bcb3
8 changed files with 121 additions and 26 deletions
@@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using Yarn.Unity;
namespace AibisDream
@@ -14,8 +15,28 @@ namespace AibisDream
private Dictionary<string, Action<YarnOption[]>> commandMap = new();
public static event Action OnDialogueStart;
public static event Action OnDialogueComplete;
private bool _isTalking;
public bool IsTalking
{
set
{
if (_isTalking == value) return;
_isTalking = value;
if (value)
{
OnDialogueStart?.Invoke();
}
else
{
OnDialogueComplete?.Invoke();
}
}
}
public static UnityAction OnDialogueStart;
public static UnityAction OnDialogueComplete;
public bool quickRunMode;
@@ -23,8 +44,10 @@ namespace AibisDream
{
dialogueRunner = GetComponentInChildren<DialogueRunner>();
_variableStorage = GetComponentInChildren<InMemoryVariableStorage>();
dialogueRunner.onDialogueStart.AddListener(() => OnDialogueStart?.Invoke());
dialogueRunner.onDialogueComplete.AddListener(() => OnDialogueComplete?.Invoke());
dialogueRunner.onDialogueStart.AddListener(() => { OnDialogueStart?.Invoke(); });
dialogueRunner.onDialogueComplete.AddListener(() => { OnDialogueComplete?.Invoke(); });
dialogueRunner.AddCommandListener(_ => { IsTalking = false; });
}
#region
@@ -38,12 +61,12 @@ namespace AibisDream
{
_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);
@@ -95,8 +118,7 @@ namespace AibisDream
{
Debug.Log($"命令 {commandName} 已经存在,将被替换");
}
Debug.Log(commandMap == null);
commandMap[commandName] = commandAction;
}
@@ -137,7 +159,6 @@ namespace AibisDream
[YarnCommand("character_init")]
public static void CharacterInit(string picName)
{
Debug.Log(picName);
MainSceneController.Instance.Guest.SwitchImage(picName);
MainSceneController.Instance.Guest.Show();
}