遮罩问题
This commit is contained in:
@@ -9,6 +9,8 @@ namespace AibisDream
|
||||
{
|
||||
public class DialogController : Singleton<DialogController>
|
||||
{
|
||||
private const string BookManager = "BookManager";
|
||||
|
||||
private DialogueRunner dialogueRunner;
|
||||
|
||||
private VariableStorageBehaviour _variableStorage;
|
||||
@@ -35,6 +37,9 @@ namespace AibisDream
|
||||
}
|
||||
}
|
||||
|
||||
// 对话框被阻塞时不能继续对话框交互
|
||||
public bool IsBlock { get; set; }
|
||||
|
||||
public static UnityAction OnDialogueStart;
|
||||
public static UnityAction OnDialogueComplete;
|
||||
|
||||
@@ -44,7 +49,12 @@ namespace AibisDream
|
||||
{
|
||||
dialogueRunner = GetComponentInChildren<DialogueRunner>();
|
||||
_variableStorage = GetComponentInChildren<InMemoryVariableStorage>();
|
||||
|
||||
|
||||
// 开关书交互
|
||||
BookManager bookManager = GameObject.Find(BookManager).gameObject.GetComponent<BookManager>();
|
||||
bookManager.OnBookClosed += () => { IsBlock = false; };
|
||||
bookManager.OnBookOpen += () => { IsBlock = true; };
|
||||
|
||||
dialogueRunner.onDialogueStart.AddListener(() => { OnDialogueStart?.Invoke(); });
|
||||
dialogueRunner.onDialogueComplete.AddListener(() => { OnDialogueComplete?.Invoke(); });
|
||||
dialogueRunner.AddCommandListener(_ => { IsTalking = false; });
|
||||
|
||||
@@ -79,6 +79,11 @@ namespace AibisDream
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (DialogController.Instance.IsBlock)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DialogUiViewer.Instance.TrySkipLine())
|
||||
{
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using UnityEngine;
|
||||
using Yarn.Unity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using AibisDream;
|
||||
using System.Linq;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
using System.Numerics;
|
||||
|
||||
public class BookManager : MonoBehaviour
|
||||
{
|
||||
public Book book; // Reference to the book script
|
||||
@@ -19,8 +18,9 @@ public class BookManager : MonoBehaviour
|
||||
|
||||
private RectTransform bookPos;
|
||||
|
||||
public event System.Action OnBookClosed;
|
||||
public event Action OnBookClosed;
|
||||
|
||||
public event Action OnBookOpen;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -30,25 +30,28 @@ public class BookManager : MonoBehaviour
|
||||
// 仅关闭书本,不执行额外操作
|
||||
CloseBook();
|
||||
});
|
||||
|
||||
OepnBookButton.onClick.RemoveAllListeners(); // 确保不会重复绑定
|
||||
OepnBookButton.onClick.AddListener(() =>
|
||||
{
|
||||
// 打开书本
|
||||
ButtonOpenBook();
|
||||
});
|
||||
|
||||
DialogController.Instance.RegisterOptionCommand("listen_closeBook", CombineCloseBook);
|
||||
flipmanager=book.gameObject.GetComponent<AutoFlip>();
|
||||
bookPos=book.gameObject.GetComponent<RectTransform>();
|
||||
flipmanager = book.gameObject.GetComponent<AutoFlip>();
|
||||
bookPos = book.gameObject.GetComponent<RectTransform>();
|
||||
// Initially, the book is closed
|
||||
CloseBook();
|
||||
}
|
||||
// Open the book and flip to a specific page
|
||||
|
||||
public void CombineCloseBook(YarnOption[] options)
|
||||
{
|
||||
var optionDic = options.ToDictionary(item => item.Text, item => item);
|
||||
Debug.Log("Option dictionary keys: " + string.Join(", ", optionDic.Keys));
|
||||
public void CombineCloseBook(YarnOption[] options)
|
||||
{
|
||||
var optionDic = options.ToDictionary(item => item.Text, item => item);
|
||||
Debug.Log("Option dictionary keys: " + string.Join(", ", optionDic.Keys));
|
||||
|
||||
if (optionDic.ContainsKey("CloseBook"))
|
||||
if (optionDic.ContainsKey("CloseBook"))
|
||||
{
|
||||
// 监听书关闭事件
|
||||
OnBookClosed -= TriggerCloseBookOption; // 避免重复监听
|
||||
@@ -67,10 +70,10 @@ public void CombineCloseBook(YarnOption[] options)
|
||||
StartCoroutine(OpenBook());
|
||||
}
|
||||
|
||||
[YarnCommand("OpenBook")]
|
||||
|
||||
public IEnumerator OpenBook()
|
||||
[YarnCommand("OpenBook")]
|
||||
public IEnumerator OpenBook()
|
||||
{
|
||||
OnBookOpen?.Invoke();
|
||||
// 如果书还没有激活,先激活它
|
||||
if (!book.gameObject.activeInHierarchy)
|
||||
{
|
||||
@@ -81,37 +84,41 @@ public IEnumerator OpenBook()
|
||||
Sequence sequence = DOTween.Sequence();
|
||||
|
||||
// 设置初始位置为屏幕外或者其他你想要的位置(根据需求自行设置)
|
||||
bookPos.anchoredPosition = new UnityEngine.Vector2(bookPos.anchoredPosition.x, -(Screen.height+bookPos.sizeDelta.y)/2);
|
||||
bookPos.anchoredPosition =
|
||||
new Vector2(bookPos.anchoredPosition.x, -(Screen.height + bookPos.sizeDelta.y) / 2);
|
||||
|
||||
// 移动到目标位置
|
||||
sequence.Append(bookPos.DOAnchorPos(UnityEngine.Vector2.zero, 0.5f).SetEase(Ease.OutQuad));
|
||||
sequence.Append(bookPos.DOAnchorPos(Vector2.zero, 0.5f).SetEase(Ease.OutQuad));
|
||||
|
||||
// 等待序列完成
|
||||
yield return sequence.WaitForCompletion();
|
||||
}
|
||||
|
||||
[YarnCommand("Flip")]
|
||||
|
||||
public IEnumerator FlipToPageYarnCommand(int parameters)
|
||||
{
|
||||
// Parse the target page from the parameters
|
||||
int targetPage =parameters;
|
||||
// Start the FlipToPageCoroutine and wait for it to finish
|
||||
yield return StartCoroutine(flipmanager.FlipToPageCoroutine(targetPage));
|
||||
}
|
||||
[YarnCommand("Flip")]
|
||||
public IEnumerator FlipToPageYarnCommand(int parameters)
|
||||
{
|
||||
// Parse the target page from the parameters
|
||||
int targetPage = parameters;
|
||||
// Start the FlipToPageCoroutine and wait for it to finish
|
||||
yield return StartCoroutine(flipmanager.FlipToPageCoroutine(targetPage));
|
||||
}
|
||||
|
||||
// Close the book
|
||||
public void CloseBook(Action onCloseCallback = null)
|
||||
{
|
||||
StartCoroutine(CloseBookCoroutine(onCloseCallback));
|
||||
}
|
||||
private IEnumerator CloseBookCoroutine(Action onCloseCallback = null)
|
||||
|
||||
private IEnumerator CloseBookCoroutine(Action onCloseCallback = null)
|
||||
{
|
||||
// 使用 DoTween 创建一个动画序列
|
||||
Sequence sequence = DOTween.Sequence();
|
||||
|
||||
// 动画:将 book 移动回初始位置
|
||||
sequence.Append(bookPos.DOAnchorPos(new UnityEngine.Vector2(bookPos.anchoredPosition.x, -(Screen.height+bookPos.sizeDelta.y)/2), 0.5f).SetEase(Ease.InQuad));
|
||||
sequence.Append(bookPos
|
||||
.DOAnchorPos(
|
||||
new Vector2(bookPos.anchoredPosition.x, -(Screen.height + bookPos.sizeDelta.y) / 2), 0.5f)
|
||||
.SetEase(Ease.InQuad));
|
||||
|
||||
// 等待动画完成
|
||||
yield return sequence.WaitForCompletion();
|
||||
@@ -119,8 +126,6 @@ public IEnumerator FlipToPageYarnCommand(int parameters)
|
||||
// 动画完成后隐藏 book
|
||||
book.gameObject.SetActive(false);
|
||||
|
||||
OnBookClosed?.Invoke();
|
||||
OnBookClosed?.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -74,11 +74,6 @@ namespace AibisDream
|
||||
dialogText.onTextShowed.AddListener(() => nextButton.gameObject.SetActive(true));
|
||||
|
||||
nextButton.onClick.RemoveAllListeners();
|
||||
nextButton.onClick.AddListener(() =>
|
||||
{
|
||||
nextStep.Invoke();
|
||||
nextButton.gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user