合并
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Utility;
|
||||
@@ -18,6 +19,8 @@ namespace AibisDream.FixSystem
|
||||
[SerializeField] private TMP_Text title;
|
||||
[SerializeField] private RectTransform textRoot;
|
||||
[SerializeField] private TMP_Text textForEstimation;
|
||||
[SerializeField] private int maxLineNum = 10;
|
||||
|
||||
private GameObject _textItemPrefab;
|
||||
private Queue<TypewriterByCharacter> _lineQueue;
|
||||
|
||||
@@ -25,8 +28,6 @@ namespace AibisDream.FixSystem
|
||||
|
||||
public TaskScreen TaskScreen { get; private set; }
|
||||
|
||||
public int maxLineNum = 10;
|
||||
|
||||
#endregion
|
||||
|
||||
private void Awake()
|
||||
@@ -63,7 +64,7 @@ namespace AibisDream.FixSystem
|
||||
{
|
||||
title.text = targetTitle;
|
||||
}
|
||||
|
||||
|
||||
public void ClearTextScreen()
|
||||
{
|
||||
while (_lineQueue.Count > 0)
|
||||
@@ -71,7 +72,7 @@ namespace AibisDream.FixSystem
|
||||
var text = _lineQueue.Dequeue();
|
||||
Destroy(text.gameObject);
|
||||
}
|
||||
|
||||
|
||||
ShowTitle(string.Empty);
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ namespace AibisDream.FixSystem
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public void RunLine(LineSyncToken token)
|
||||
{
|
||||
// 空格延长一点避免报错
|
||||
@@ -89,23 +90,30 @@ namespace AibisDream.FixSystem
|
||||
{
|
||||
token.lineInfo.lineText = " ";
|
||||
}
|
||||
|
||||
|
||||
// 显示标题
|
||||
ShowTitle(token.lineInfo.character.GetActorName());
|
||||
// 显示文本
|
||||
TypewriterCore textItemTypewriter = AddText(token.lineInfo.lineText);
|
||||
textItemTypewriter.SetTypewriterSpeed(GetTextSpeedValue());
|
||||
textItemTypewriter.onTextShowed.AddListener(() => OnTextShown(token, textItemTypewriter));
|
||||
token.state = LineSyncState.PlayText;
|
||||
token.TextStart();
|
||||
// 强制更新布局
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(textRoot);
|
||||
}
|
||||
|
||||
private float GetTextSpeedValue()
|
||||
{
|
||||
var textSpeedStr = SettingLoader.Instance.TryRead("TextSpeed", out string textSpeed) ? textSpeed : "1";
|
||||
return float.TryParse(textSpeedStr, NumberStyles.Float, CultureInfo.InvariantCulture, out float result) ? result : 1f;
|
||||
}
|
||||
|
||||
private void OnTextShown(LineSyncToken syncToken, TypewriterCore typewriter)
|
||||
{
|
||||
typewriter.onTextShowed.RemoveAllListeners();
|
||||
syncToken.TextShown();
|
||||
}
|
||||
|
||||
|
||||
private TypewriterByCharacter AddText(string newLine)
|
||||
{
|
||||
// 生成新文本组件
|
||||
@@ -119,13 +127,13 @@ namespace AibisDream.FixSystem
|
||||
Destroy(_lineQueue.Dequeue().gameObject);
|
||||
}
|
||||
_lineQueue.Enqueue(textItemTypewriter);
|
||||
|
||||
|
||||
// 播放文本
|
||||
textItemTypewriter.ShowText(newLine);
|
||||
|
||||
return textItemTypewriter;
|
||||
}
|
||||
|
||||
|
||||
private int EstimateLineNum(string text)
|
||||
{
|
||||
textForEstimation.text = text;
|
||||
|
||||
Reference in New Issue
Block a user