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(),