From d4055adbcefe039f1b687720af40bd9d40c9246e Mon Sep 17 00:00:00 2001 From: SepComet <202308010230@stu.csust.edu.cn> Date: Thu, 12 Feb 2026 21:58:05 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=AE=8C=E5=96=84=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E7=9A=84=E5=85=B7=E4=BD=93=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E5=85=A8=E5=B1=80=E6=80=A7=E7=9A=84=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9=E5=B7=B2=E7=BB=8F=E5=8F=AF=E4=BB=A5=E5=8F=91=E6=8C=A5?= =?UTF-8?q?=E4=BD=9C=E7=94=A8=E4=BA=86=20-=20=E8=B0=83=E6=95=B4=E9=83=A8?= =?UTF-8?q?=E5=88=86=E9=A1=B9=E7=9B=AE=E7=BB=93=E6=9E=84=E5=92=8CAB?= =?UTF-8?q?=E5=8C=85=E8=AE=BE=E7=BD=AE=EF=BC=8C=E6=89=93=E5=8C=85=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=AE=BE=E7=BD=AE=E9=9D=A2=E6=9D=BF=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/CustomComponent/DialogComponent.cs | 14 ++++---------- .../GameMain/Scripts/Setting/SettingExtension.cs | 2 +- .../Scripts/UI/Context/DialogFormContext.cs | 2 +- .../GameMain/Scripts/UI/View/BottomDialogForm.cs | 10 ++++++++-- Assets/GameMain/Scripts/UI/View/MaskDialogForm.cs | 9 ++++++++- Assets/GameMain/Scripts/UI/View/SelectableItem.cs | 13 +++++++++++-- Assets/GameMain/Scripts/UI/View/SettingForm.cs | 8 ++++---- 7 files changed, 37 insertions(+), 21 deletions(-) diff --git a/Assets/GameMain/Scripts/CustomComponent/DialogComponent.cs b/Assets/GameMain/Scripts/CustomComponent/DialogComponent.cs index e196c00..38b81fe 100644 --- a/Assets/GameMain/Scripts/CustomComponent/DialogComponent.cs +++ b/Assets/GameMain/Scripts/CustomComponent/DialogComponent.cs @@ -15,9 +15,7 @@ namespace CustomComponent public class DialogComponent : GameFrameworkComponent { #region Property - - [SerializeField] private float _playingSpeed = 1.0f; - + private const int DialogChapterDivisor = 1000; private const int LineChapterDivisor = 100000000; private const int LineDialogDivisor = 100000; @@ -37,9 +35,7 @@ namespace CustomComponent private int _currentLineIndex = -1; private bool _isInitialized; private bool _isPlaying; - - public float PlayingSpeed => _playingSpeed; - + public bool IsInitialized => _isInitialized; public bool IsPlaying => _isPlaying; @@ -216,9 +212,8 @@ namespace CustomComponent _formContext.DialogId = dialogRow.Id; _formContext.DialogTitle = dialogRow.Title; _formContext.DialogUIMode = dialogRow.UIMode; - _formContext.PlayingSpeed = Mathf.Max(0f, _playingSpeed); - _formContext.DialogWindowAlpha = - (DialogWindowAlpha)GameEntry.Setting.GetInt(Constant.Setting.DialogWindowAlpha); + _formContext.PlayingSpeed = (DialogPlayingSpeed)GameEntry.Setting.GetInt(Constant.Setting.DialogPlayingSpeed); + _formContext.DialogWindowAlpha = (DialogWindowAlpha)GameEntry.Setting.GetInt(Constant.Setting.DialogWindowAlpha); _currentLineIndex = 0; ApplyLineToContext(dialogLines[_currentLineIndex], _currentLineIndex, dialogLines.Count); @@ -358,7 +353,6 @@ namespace CustomComponent _formContext.Direction = lineRow.Direction; _formContext.Text = lineRow.Text; _formContext.Emphasis = lineRow.Emphasis; - _formContext.PlayingSpeed = Mathf.Max(0f, _playingSpeed); _formContext.LineIndex = lineIndex; _formContext.TotalLines = totalLines; _formContext.IsLastLine = lineIndex >= totalLines - 1; diff --git a/Assets/GameMain/Scripts/Setting/SettingExtension.cs b/Assets/GameMain/Scripts/Setting/SettingExtension.cs index 9a0a15a..7713b4a 100644 --- a/Assets/GameMain/Scripts/Setting/SettingExtension.cs +++ b/Assets/GameMain/Scripts/Setting/SettingExtension.cs @@ -17,7 +17,7 @@ namespace Setting AllowShake = setting.GetBool(Constant.Setting.AllowShake, true), AllowBlink = setting.GetBool(Constant.Setting.AllowBlink, true), - DialogWindowAlpha = (DialogWindowAlpha)setting.GetInt(Constant.Setting.DialogWindowAlpha, 1), + DialogWindowAlpha = (DialogWindowAlpha)setting.GetInt(Constant.Setting.DialogWindowAlpha, 2), DialogPlayingSpeed = (DialogPlayingSpeed)setting.GetInt(Constant.Setting.DialogPlayingSpeed, 1), ScreenResolution = (ScreenResolutionType)setting.GetInt(Constant.Setting.ScreenSolution, 1), diff --git a/Assets/GameMain/Scripts/UI/Context/DialogFormContext.cs b/Assets/GameMain/Scripts/UI/Context/DialogFormContext.cs index 5cef4ff..0966ca3 100644 --- a/Assets/GameMain/Scripts/UI/Context/DialogFormContext.cs +++ b/Assets/GameMain/Scripts/UI/Context/DialogFormContext.cs @@ -4,7 +4,7 @@ namespace UI { public class DialogFormContext : UIContext { - public float PlayingSpeed = 1f; + public DialogPlayingSpeed PlayingSpeed = DialogPlayingSpeed.Medium; public int ChapterId = 0; public int DialogId = 0; diff --git a/Assets/GameMain/Scripts/UI/View/BottomDialogForm.cs b/Assets/GameMain/Scripts/UI/View/BottomDialogForm.cs index d0319d1..54a3ac5 100644 --- a/Assets/GameMain/Scripts/UI/View/BottomDialogForm.cs +++ b/Assets/GameMain/Scripts/UI/View/BottomDialogForm.cs @@ -39,6 +39,7 @@ namespace UI private string _rightSpeakerToken = string.Empty; private Sequence _layoutSequence; private DialogWindowAlpha _currentWindowAlpha = DialogWindowAlpha.Medium; + private float _currentPlayingSpeed = 10f; public override void StartDialog(DialogFormContext context) { @@ -61,7 +62,7 @@ namespace UI DialogWindowAlpha.High => 0.25f, _ => 0.5f }; - + if (_dialogBgImages.Length == 0) { //TODO:一个很奇怪的问题,在 prefab 里赋好的值实例化出来就没了,只能先这样赋值 @@ -76,6 +77,11 @@ namespace UI } } + if ((int)(_context.PlayingSpeed + 1) * 5 != (int)_currentPlayingSpeed) + { + _currentPlayingSpeed = 5f * (int)(_context.PlayingSpeed + 1); + } + string speakerName = _context.SpeakerName; if (_speakerArea != null) @@ -88,7 +94,7 @@ namespace UI _speakerNameText.text = speakerName; } - PlayTypewriter(_contentText, _context.Text, _context.PlayingSpeed); + PlayTypewriter(_contentText, _context.Text, _currentPlayingSpeed); if (string.IsNullOrEmpty(speakerName)) { diff --git a/Assets/GameMain/Scripts/UI/View/MaskDialogForm.cs b/Assets/GameMain/Scripts/UI/View/MaskDialogForm.cs index 0673233..754be40 100644 --- a/Assets/GameMain/Scripts/UI/View/MaskDialogForm.cs +++ b/Assets/GameMain/Scripts/UI/View/MaskDialogForm.cs @@ -13,6 +13,8 @@ namespace UI [SerializeField] private Image _maskImage; [SerializeField] private TMP_Text _text; + + private float _currentPlayingSpeed; public override void StartDialog(DialogFormContext context) { @@ -29,7 +31,12 @@ namespace UI _maskImage.gameObject.SetActive(true); } - PlayTypewriter(_text, context.Text, context.PlayingSpeed); + if ((int)_context.PlayingSpeed * 5 != (int)_currentPlayingSpeed) + { + _currentPlayingSpeed = 5f * (int)_context.PlayingSpeed; + } + + PlayTypewriter(_text, context.Text, _currentPlayingSpeed); } } } diff --git a/Assets/GameMain/Scripts/UI/View/SelectableItem.cs b/Assets/GameMain/Scripts/UI/View/SelectableItem.cs index 82b0264..1b898a1 100644 --- a/Assets/GameMain/Scripts/UI/View/SelectableItem.cs +++ b/Assets/GameMain/Scripts/UI/View/SelectableItem.cs @@ -20,7 +20,7 @@ namespace UI public void OnPointerEnter(PointerEventData eventData) { - _fadeSequence.Kill(); + KillFadeSequence(); _fadeSequence = DOTween.Sequence(); _fadeSequence.Append(_bgImage.DOFade(1, _fadeDuration)); _onSelect.Invoke(); @@ -28,10 +28,19 @@ namespace UI public void OnPointerExit(PointerEventData eventData) { - _fadeSequence.Kill(); + KillFadeSequence(); + _fadeSequence = DOTween.Sequence(); _fadeSequence.Append(_bgImage.DOFade(0, _fadeDuration)); _onDeselect.Invoke(); } + + private void KillFadeSequence() + { + if (_fadeSequence != null && _fadeSequence.IsActive()) + { + _fadeSequence.Kill(); + } + } } } \ No newline at end of file diff --git a/Assets/GameMain/Scripts/UI/View/SettingForm.cs b/Assets/GameMain/Scripts/UI/View/SettingForm.cs index 9f5f607..d4fbc75 100644 --- a/Assets/GameMain/Scripts/UI/View/SettingForm.cs +++ b/Assets/GameMain/Scripts/UI/View/SettingForm.cs @@ -46,8 +46,8 @@ namespace UI var setting = context.Setting; - _bgmVolumeSlider.value = setting.BGMVolume * 4; - _seVolumeSlider.value = setting.SEVolume * 4; + _bgmVolumeSlider.value = setting.BGMVolume * 5; + _seVolumeSlider.value = setting.SEVolume * 5; _allowBlinkGroup.SetValue(setting.AllowBlink); _allowShakeGroup.SetValue(setting.AllowShake); @@ -77,8 +77,8 @@ namespace UI { var setting = new GameSetting { - BGMVolume = _bgmVolumeSlider.value / 4, - SEVolume = _seVolumeSlider.value / 4, + BGMVolume = _bgmVolumeSlider.value / 5, + SEVolume = _seVolumeSlider.value / 5, AllowShake = _allowShakeGroup.GetBoolValue(), AllowBlink = _allowBlinkGroup.GetBoolValue(),