From 55952aa38ca1a3a0ca605c564421bc198aedc74a Mon Sep 17 00:00:00 2001 From: Ding Yuntian <1491671119@qq.com> Date: Wed, 18 Jun 2025 14:51:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=8A=E7=96=97=E8=AE=B0=E5=BD=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scenes/Persistence.unity | 2 +- Assets/Scripts/FixSystemNew/FixStateMachine.cs | 5 ++--- Assets/Scripts/Game Loop/EventEnums.cs | 5 +++-- Assets/Scripts/Utility/CommonUtil.cs | 12 +++++++----- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Assets/Scenes/Persistence.unity b/Assets/Scenes/Persistence.unity index eff704614..32122fc02 100644 --- a/Assets/Scenes/Persistence.unity +++ b/Assets/Scenes/Persistence.unity @@ -10452,7 +10452,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: runMode: 0 - firstTalkSo: {fileID: 11400000, guid: afc5b01ef301cc74db7cae741acad427, type: 2} + firstTalkSo: {fileID: 11400000, guid: 2f763a2c04ecafb4981379b7363f9791, type: 2} testTalkSo: {fileID: 11400000, guid: 2f763a2c04ecafb4981379b7363f9791, type: 2} saveFileName: --- !u!1 &719273460 diff --git a/Assets/Scripts/FixSystemNew/FixStateMachine.cs b/Assets/Scripts/FixSystemNew/FixStateMachine.cs index be55506dc..e725a9c6b 100644 --- a/Assets/Scripts/FixSystemNew/FixStateMachine.cs +++ b/Assets/Scripts/FixSystemNew/FixStateMachine.cs @@ -11,7 +11,6 @@ namespace AibisDream.FixSystem public FixState CurState => _curState.GetState; private IState _curState; - private string _curArgs; private StateMachine _stateMachine; @@ -27,14 +26,14 @@ namespace AibisDream.FixSystem public IEnumerator Init(FixState initState) { _data.curState = initState; - _curArgs = ""; + _data.args = ""; yield return _stateMachine.Init(initState); } public IEnumerator SwitchState(FixState nextState, string args = "") { _data.curState = nextState; - _curArgs = args; + _data.args = args; yield return _stateMachine.SwitchState(nextState, args); } diff --git a/Assets/Scripts/Game Loop/EventEnums.cs b/Assets/Scripts/Game Loop/EventEnums.cs index 830d4cae7..345cfdca1 100644 --- a/Assets/Scripts/Game Loop/EventEnums.cs +++ b/Assets/Scripts/Game Loop/EventEnums.cs @@ -1,4 +1,5 @@ -using AibisDream.Kit; +using System.Text.RegularExpressions; +using AibisDream.Kit; using AibisDream.Utility; using Yarn.Unity; @@ -53,7 +54,7 @@ namespace AibisDream public string GetDialogText() { // 先去掉换行 - var realLine = line.Replace("
", ""); + var realLine = Regex.Replace(line, "[<|{].*?[>|}]", string.Empty); if (!isOption) { diff --git a/Assets/Scripts/Utility/CommonUtil.cs b/Assets/Scripts/Utility/CommonUtil.cs index cbccae4ff..e4954a4ef 100644 --- a/Assets/Scripts/Utility/CommonUtil.cs +++ b/Assets/Scripts/Utility/CommonUtil.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Unity.VisualScripting; using UnityEngine; @@ -85,7 +86,7 @@ namespace AibisDream.Utility } var range = max - min + 1; - + // 计算新的目标值 var newTarget = target + step; @@ -115,7 +116,7 @@ namespace AibisDream.Utility foreach (var sourceField in sourceFields) { if (sourceField.IsStatic) return; - + var targetField = targetFields.FirstOrDefault(p => p.Name == sourceField.Name && p.FieldType == sourceField.FieldType); if (targetField != null && !targetField.IsStatic()) @@ -165,7 +166,7 @@ namespace AibisDream.Utility } #endregion - + /// /// 去除原始对话中名称部分 /// @@ -176,7 +177,7 @@ namespace AibisDream.Utility var textArr = lineText.Split(":"); return textArr.Length > 1 ? textArr[1].Trim() : lineText; } - + /// /// 拆分字符串为若干行 /// @@ -203,7 +204,8 @@ namespace AibisDream.Utility var substring = line.Substring(currentIndex, length); // 检查是否需要调整长度以避免在单词中间断开 - if (currentIndex + length < line.Length && !char.IsWhiteSpace(line[currentIndex + length]) && !char.IsPunctuation(line[currentIndex + length])) + if (currentIndex + length < line.Length && !char.IsWhiteSpace(line[currentIndex + length]) && + !char.IsPunctuation(line[currentIndex + length])) { var lastSpace = substring.LastIndexOf(' '); if (lastSpace > 0)