From 57649da49001cd10ff11bb4945ea2d06b5b1b80c Mon Sep 17 00:00:00 2001 From: SepComet <202308010230@stu.csust.edu.cn> Date: Thu, 12 Feb 2026 21:11:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=AF=B9=E8=AF=9D=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E7=9A=84=E9=80=8F=E6=98=8E=E5=BA=A6=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomComponent/DialogComponent.cs | 7 +++- .../Scripts/Procedure/ProcedureMenu.cs | 16 ++++++++ .../Scripts/UI/Context/DialogFormContext.cs | 2 + .../Scripts/UI/View/BottomDialogForm.cs | 37 +++++++++++++++++-- .../UI/UIForms/BottomBoxDialogForm.prefab | 7 +++- 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/Assets/GameMain/Scripts/CustomComponent/DialogComponent.cs b/Assets/GameMain/Scripts/CustomComponent/DialogComponent.cs index 0581337..e196c00 100644 --- a/Assets/GameMain/Scripts/CustomComponent/DialogComponent.cs +++ b/Assets/GameMain/Scripts/CustomComponent/DialogComponent.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using DataTable; +using Definition; using Definition.Enum; using Event; using GameFramework.DataTable; @@ -16,7 +17,7 @@ namespace CustomComponent #region Property [SerializeField] private float _playingSpeed = 1.0f; - + private const int DialogChapterDivisor = 1000; private const int LineChapterDivisor = 100000000; private const int LineDialogDivisor = 100000; @@ -216,6 +217,8 @@ namespace CustomComponent _formContext.DialogTitle = dialogRow.Title; _formContext.DialogUIMode = dialogRow.UIMode; _formContext.PlayingSpeed = Mathf.Max(0f, _playingSpeed); + _formContext.DialogWindowAlpha = + (DialogWindowAlpha)GameEntry.Setting.GetInt(Constant.Setting.DialogWindowAlpha); _currentLineIndex = 0; ApplyLineToContext(dialogLines[_currentLineIndex], _currentLineIndex, dialogLines.Count); @@ -410,4 +413,4 @@ namespace CustomComponent #endregion } -} +} \ No newline at end of file diff --git a/Assets/GameMain/Scripts/Procedure/ProcedureMenu.cs b/Assets/GameMain/Scripts/Procedure/ProcedureMenu.cs index 2ddc29c..7b0aa86 100644 --- a/Assets/GameMain/Scripts/Procedure/ProcedureMenu.cs +++ b/Assets/GameMain/Scripts/Procedure/ProcedureMenu.cs @@ -10,6 +10,7 @@ using Sound; using UI; using UnityEngine; using UnityEngine.Rendering; +using UnityGameFramework.Runtime; namespace Procedure @@ -23,9 +24,13 @@ namespace Procedure private SettingFormController _settingFormController; private const string SettingPrefix = "Setting."; + + private bool _gameStarted = false; private void StartGame() { + if (_gameStarted) return; + _gameStarted = true; } private void LoadGame() @@ -71,6 +76,9 @@ namespace Procedure protected override void OnLeave(IFsm procedureOwner, bool isShutdown) { + _menuFormController?.CloseUI(); + _settingFormController?.CloseUI(); + var e = GameEntry.Event; e.Unsubscribe(MenuStartEventArgs.EventId, MenuStart); e.Unsubscribe(MenuContinueEventArgs.EventId, MenuContinue); @@ -85,6 +93,12 @@ namespace Procedure float realElapseSeconds) { base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds); + + if (_gameStarted) + { + procedureOwner.SetData("NextSceneId", (int)SceneId.GameplayA); + ChangeState(procedureOwner); + } } #endregion @@ -94,11 +108,13 @@ namespace Procedure private void MenuStart(object sender, GameEventArgs e) { if (!(e is MenuStartEventArgs)) return; + StartGame(); } private void MenuContinue(object sender, GameEventArgs e) { if (!(e is MenuContinueEventArgs)) return; + LoadGame(); } private void MenuSetting(object sender, GameEventArgs e) diff --git a/Assets/GameMain/Scripts/UI/Context/DialogFormContext.cs b/Assets/GameMain/Scripts/UI/Context/DialogFormContext.cs index 46ec048..5cef4ff 100644 --- a/Assets/GameMain/Scripts/UI/Context/DialogFormContext.cs +++ b/Assets/GameMain/Scripts/UI/Context/DialogFormContext.cs @@ -22,5 +22,7 @@ namespace UI public int LineIndex = -1; public int TotalLines = 0; public bool IsLastLine = false; + + public DialogWindowAlpha DialogWindowAlpha = DialogWindowAlpha.Medium; } } diff --git a/Assets/GameMain/Scripts/UI/View/BottomDialogForm.cs b/Assets/GameMain/Scripts/UI/View/BottomDialogForm.cs index 04622a3..d0319d1 100644 --- a/Assets/GameMain/Scripts/UI/View/BottomDialogForm.cs +++ b/Assets/GameMain/Scripts/UI/View/BottomDialogForm.cs @@ -1,4 +1,6 @@ -using DG.Tweening; +using System.Collections.Generic; +using System.Linq; +using DG.Tweening; using Definition.Enum; using TMPro; using UnityEngine; @@ -28,12 +30,15 @@ namespace UI [SerializeField] private float _moveDuration = 0.25f; [SerializeField] private Ease _moveEase = Ease.OutCubic; - + + [SerializeField] private Image[] _dialogBgImages; + private readonly int _singleSpeakerCenterPosition = Screen.width / 2; private string _leftSpeakerToken = string.Empty; private string _rightSpeakerToken = string.Empty; private Sequence _layoutSequence; + private DialogWindowAlpha _currentWindowAlpha = DialogWindowAlpha.Medium; public override void StartDialog(DialogFormContext context) { @@ -45,6 +50,32 @@ namespace UI _context = context; + if (_context.DialogWindowAlpha != this._currentWindowAlpha) + { + _currentWindowAlpha = _context.DialogWindowAlpha; + float targetAlpha = _currentWindowAlpha switch + { + DialogWindowAlpha.None => 1, + DialogWindowAlpha.Low => 0.75f, + DialogWindowAlpha.Medium => 0.5f, + DialogWindowAlpha.High => 0.25f, + _ => 0.5f + }; + + if (_dialogBgImages.Length == 0) + { + //TODO:一个很奇怪的问题,在 prefab 里赋好的值实例化出来就没了,只能先这样赋值 + _dialogBgImages = GetComponentsInChildren().Where(image => image.name == "bg").ToArray(); + } + + foreach (Image image in _dialogBgImages) + { + Color color = image.color; + color.a = targetAlpha; + image.color = color; + } + } + string speakerName = _context.SpeakerName; if (_speakerArea != null) @@ -277,4 +308,4 @@ namespace UI rectTransform.anchoredPosition = anchoredPosition; } } -} +} \ No newline at end of file diff --git a/Assets/GameMain/UI/UIForms/BottomBoxDialogForm.prefab b/Assets/GameMain/UI/UIForms/BottomBoxDialogForm.prefab index 44adac9..18bf7ba 100644 --- a/Assets/GameMain/UI/UIForms/BottomBoxDialogForm.prefab +++ b/Assets/GameMain/UI/UIForms/BottomBoxDialogForm.prefab @@ -474,7 +474,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Color: {r: 1, g: 1, b: 1, a: 0.5019608} m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -586,7 +586,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0.39215687, g: 0.39215687, b: 0.39215687, a: 0.39215687} + m_Color: {r: 0.39215687, g: 0.39215687, b: 0.39215687, a: 0.5019608} m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -664,6 +664,9 @@ MonoBehaviour: _rightSpritePosition: -450 _moveDuration: 0.25 _moveEase: 9 + _dialogBgImages: + - {fileID: 7254061520918156868} + - {fileID: 8566667250576683572} --- !u!1 &6371466324854950042 GameObject: m_ObjectHideFlags: 0