Merge branch 'bugfix/cover' into 'develop'
Bugfix/cover See merge request aibis-dream/aibis-dream!33
This commit is contained in:
@@ -1339,7 +1339,7 @@ MonoBehaviour:
|
||||
runMode: 1
|
||||
firstTalkSO: {fileID: 11400000, guid: 10601ce26230723479d875a630f15732, type: 2}
|
||||
clinicScene: ClinicScene
|
||||
testYarnProject: CutLine
|
||||
testYarnProject: OptionTest
|
||||
--- !u!4 &719228339
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1505,6 +1505,82 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 761395782}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &773911909
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 773911910}
|
||||
- component: {fileID: 773911912}
|
||||
- component: {fileID: 773911911}
|
||||
m_Layer: 5
|
||||
m_Name: Show Obj
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!224 &773911910
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 773911909}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 2038437602}
|
||||
m_Father: {fileID: 984233631}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &773911911
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 773911909}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0, g: 0, b: 0, a: 0.5411765}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &773911912
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 773911909}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &783911286
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1918,6 +1994,7 @@ RectTransform:
|
||||
- {fileID: 731599308}
|
||||
- {fileID: 614046222}
|
||||
- {fileID: 761395783}
|
||||
- {fileID: 773911910}
|
||||
m_Father: {fileID: 1343879457}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
@@ -3351,7 +3428,7 @@ MonoBehaviour:
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_Bits: 0
|
||||
--- !u!114 &1604842427
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4344,6 +4421,81 @@ MonoBehaviour:
|
||||
onCommand:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1 &2038437601
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2038437602}
|
||||
- component: {fileID: 2038437604}
|
||||
- component: {fileID: 2038437603}
|
||||
m_Layer: 5
|
||||
m_Name: Obj
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2038437602
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2038437601}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 773911910}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &2038437603
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2038437601}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &2038437604
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2038437601}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &2056178948
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -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; });
|
||||
@@ -230,6 +240,18 @@ namespace AibisDream
|
||||
return MainUIController.Instance.FadeOutSync(duration);
|
||||
}
|
||||
|
||||
[YarnCommand("show_obj")]
|
||||
public static IEnumerator ShowObj(string picName)
|
||||
{
|
||||
return MainUIController.Instance.ShowObj(picName);
|
||||
}
|
||||
|
||||
[YarnCommand("hide_obj")]
|
||||
public static IEnumerator HideObj()
|
||||
{
|
||||
return MainUIController.Instance.HideObj();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AibisDream
|
||||
@@ -8,21 +9,24 @@ namespace AibisDream
|
||||
private const string TVScene = "TV Scene";
|
||||
private const string BlackImage = "Fade Image";
|
||||
private const string NewsImage = "News";
|
||||
private const string ObjPanel = "Show Obj";
|
||||
|
||||
#region 主场景图片
|
||||
|
||||
private FadeImage _tvScene;
|
||||
private FadeImage _blackImage;
|
||||
private FadeImage _news;
|
||||
private GameObject _objPanel;
|
||||
private FadeImage _objImage;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
InitChildObj();
|
||||
}
|
||||
|
||||
|
||||
#region 基本淡入淡出
|
||||
|
||||
public void FadeIn(float duration)
|
||||
@@ -88,6 +92,27 @@ namespace AibisDream
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示物体
|
||||
/// </summary>
|
||||
/// <returns>协程</returns>
|
||||
public IEnumerator ShowObj(string picName)
|
||||
{
|
||||
_objPanel.gameObject.SetActive(true);
|
||||
_objImage.SwitchImage($"Art/Obj/{picName}");
|
||||
return _objImage.FadeInSync(1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏物体
|
||||
/// </summary>
|
||||
/// <returns>协程</returns>
|
||||
public IEnumerator HideObj()
|
||||
{
|
||||
yield return _objImage.FadeOutSync(1);
|
||||
_objPanel.SetActive(false);
|
||||
}
|
||||
|
||||
private void InitChildObj()
|
||||
{
|
||||
var rawTvScene = transform.Find(TVScene).gameObject.GetComponent<Image>();
|
||||
@@ -98,6 +123,10 @@ namespace AibisDream
|
||||
|
||||
var rawNews = transform.Find(NewsImage).gameObject.GetComponent<Image>();
|
||||
_news = new FadeImage(rawNews);
|
||||
|
||||
_objPanel = transform.Find(ObjPanel).gameObject;
|
||||
var rawObj = _objPanel.transform.GetChild(0).GetComponent<Image>();
|
||||
_objImage = new FadeImage(rawObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user