From e8a7e1c289c084b765a06c5c018212fc3081a58d Mon Sep 17 00:00:00 2001 From: NTG_Lenovo Date: Tue, 22 Jul 2025 12:55:04 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=9E=84=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A0=95=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../So/ManagerDefinitionSo.asset | 1 - Assets/_DDD/_Scripts/GameEvent/GameEvents.cs | 78 +++++++------------ .../Scene/FadeSceneTransitionHandlerSo.cs | 8 +- Assets/_DDD/_Scripts/GameUi/UiManager.cs | 31 ++++++-- 4 files changed, 56 insertions(+), 62 deletions(-) diff --git a/Assets/_DDD/_ScriptAssets/So/ManagerDefinitionSo.asset b/Assets/_DDD/_ScriptAssets/So/ManagerDefinitionSo.asset index 5fedeb58b..4d6209d06 100644 --- a/Assets/_DDD/_ScriptAssets/So/ManagerDefinitionSo.asset +++ b/Assets/_DDD/_ScriptAssets/So/ManagerDefinitionSo.asset @@ -20,6 +20,5 @@ MonoBehaviour: - {fileID: 6471498998539637564, guid: fa2ad62c75b1549f09597e47ed5f7cfb, type: 3} - {fileID: 7665229218737596710, guid: 71b177c2a18314c588da30429451666a, type: 3} - {fileID: 622422277636247943, guid: d95124918e5a4a246abb0d378b14d3fa, type: 3} - - {fileID: 5136368050551183548, guid: 0aa6654feb91ef040b8b99d4f64688fc, type: 3} - {fileID: 5539371897028506726, guid: 21cff8c1505cd8041a474795e35e0192, type: 3} - {fileID: 8500549904376788358, guid: d81cf4649bf54485a8b0da7a235f3817, type: 3} diff --git a/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs b/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs index 796c75430..61be50474 100644 --- a/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs +++ b/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs @@ -4,16 +4,25 @@ namespace DDD { - // public static class GameEvents - // { - // public static RequestTimeScaleChangeEvent RequestTimeScaleChangeEvent = new(); - // public static RequestShowGlobalMessageEvent RequestShowGlobalMessageEvent = new(); - // public static InteractionEvent Interaction = new InteractionEvent(); - // } + public static class GameEvents + { + public static TimeScaleChangeEvent RequestTimeScaleChangeEvent = new(); + public static FadeInEvent FadeInEvent = new(); + public static FadeOutEvent FadeOutEvent = new(); + public static OpenScreenUiEvent OpenScreenUiEvent = new(); + public static CloseScreenUiEvent CloseScreenUiEvent = new(); + public static OpenPopupUiEvent OpenPopupUiEvent = new(); + public static ClosePopupUiEvent ClosePopupUiEvent = new(); + public static ShowGlobalMessageEvent RequestShowGlobalMessageEvent = new(); + public static InteractionEvent Interaction = new(); + public static InventoryChangedEvent InventoryChangedEvent = new(); + } + // public static class RestaurantEvents // { // // Some events... // } + // public static class VoyageEvents // { // // Some events... @@ -21,82 +30,51 @@ namespace DDD public class TimeScaleChangeEvent : IEvent { - public readonly object Requester; - public readonly float NewTimeScale; - - public TimeScaleChangeEvent(object requester, float newTimeScale) - { - Requester = requester; - NewTimeScale = newTimeScale; - } + public object Requester; + public float NewTimeScale; } public class FadeInEvent : IEvent { - public readonly float Duration; - public readonly TaskCompletionSource CompletionSource; - - public FadeInEvent(float duration) - { - Duration = duration; - CompletionSource = new TaskCompletionSource(); - } + public float Duration; + public TaskCompletionSource CompletionSource; public Task WaitAsync() => CompletionSource.Task; } public class FadeOutEvent : IEvent { - public readonly float Duration; - public readonly TaskCompletionSource CompletionSource; - - public FadeOutEvent(float duration) - { - Duration = duration; - CompletionSource = new TaskCompletionSource(); - } + public float Duration; + public TaskCompletionSource CompletionSource; public Task WaitAsync() => CompletionSource.Task; - public static InventoryChangedEvent InventoryChangedEvent = new(); - public static InteractionEvent Interaction = new(); } public class ShowGlobalMessageEvent : IEvent { - public readonly string NewMessageKey; - public readonly float ShowDuration; - public readonly float FadeDuration; - - public ShowGlobalMessageEvent(string newMessageKey, float showDuration = 3f, float fadeDuration = 0.3f) - { - NewMessageKey = newMessageKey; - ShowDuration = showDuration; - FadeDuration = fadeDuration; - } + public string NewMessageKey; + public float ShowDuration; + public float FadeDuration; } public class OpenScreenUiEvent : IEvent { - public readonly Type UiType; - public OpenScreenUiEvent(Type uiType) => UiType = uiType; + public Type UiType; } public class CloseScreenUiEvent : IEvent { - public readonly Type UiType; - public CloseScreenUiEvent(Type uiType) => UiType = uiType; + public Type UiType; } public class OpenPopupUiEvent : IEvent { - public readonly Type UiType; - public OpenPopupUiEvent(Type uiType) => UiType = uiType; + public Type UiType; } public class ClosePopupUiEvent : IEvent { - public readonly Type UiType; - public ClosePopupUiEvent(Type uiType) => UiType = uiType; + public Type UiType; } public class InteractionEvent : IEvent diff --git a/Assets/_DDD/_Scripts/GameFramework/Scene/FadeSceneTransitionHandlerSo.cs b/Assets/_DDD/_Scripts/GameFramework/Scene/FadeSceneTransitionHandlerSo.cs index 1d2e1a428..75968582c 100644 --- a/Assets/_DDD/_Scripts/GameFramework/Scene/FadeSceneTransitionHandlerSo.cs +++ b/Assets/_DDD/_Scripts/GameFramework/Scene/FadeSceneTransitionHandlerSo.cs @@ -17,7 +17,8 @@ public class FadeSceneTransitionHandlerSo : SceneTransitionHandler public override async Task OnBeforeSceneActivate(SceneType sceneType) { - var evt = new FadeOutEvent(_fadeOutDuration); + var evt = GameEvents.FadeOutEvent; + evt.Duration = _fadeOutDuration; EventBus.Broadcast(evt); await evt.WaitAsync(); } @@ -26,8 +27,9 @@ public override async Task OnAfterSceneActivate(SceneType sceneType) { float seconds = _delayBeforeFadeIn * 1000; await Task.Delay((int)(seconds)); - - var evt = new FadeInEvent(_fadeInDuration); + + var evt = GameEvents.FadeInEvent; + evt.Duration = _fadeInDuration; EventBus.Broadcast(evt); await evt.WaitAsync(); } diff --git a/Assets/_DDD/_Scripts/GameUi/UiManager.cs b/Assets/_DDD/_Scripts/GameUi/UiManager.cs index 6867b93d2..387d1d247 100644 --- a/Assets/_DDD/_Scripts/GameUi/UiManager.cs +++ b/Assets/_DDD/_Scripts/GameUi/UiManager.cs @@ -78,7 +78,10 @@ private void CloseAllScreenUIs() if (screen.IsBlockingTime) { - EventBus.Broadcast(new TimeScaleChangeEvent(_uiPauseRequester, 1f)); + var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent; + timeScaleChangeEvent.Requester = _uiPauseRequester; + timeScaleChangeEvent.NewTimeScale = 1f; + EventBus.Broadcast(timeScaleChangeEvent); } } } @@ -93,7 +96,10 @@ public void Invoke(OpenScreenUiEvent evt) if (screen.IsBlockingTime) { - EventBus.Broadcast(new TimeScaleChangeEvent(screen, 0f)); + var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent; + timeScaleChangeEvent.Requester = screen; + timeScaleChangeEvent.NewTimeScale = 0f; + EventBus.Broadcast(timeScaleChangeEvent); } } } @@ -106,7 +112,10 @@ public void Invoke(CloseScreenUiEvent evt) if (screen.IsBlockingTime) { - EventBus.Broadcast(new TimeScaleChangeEvent(screen, 1f)); + var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent; + timeScaleChangeEvent.Requester = screen; + timeScaleChangeEvent.NewTimeScale = 1f; + EventBus.Broadcast(timeScaleChangeEvent); } } } @@ -119,20 +128,26 @@ public void Invoke(OpenPopupUiEvent evt) if (popup.IsBlockingTime) { - EventBus.Broadcast(new TimeScaleChangeEvent(popup, 0f)); + var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent; + timeScaleChangeEvent.Requester = popup; + timeScaleChangeEvent.NewTimeScale = 0f; + EventBus.Broadcast(timeScaleChangeEvent); } } } public void Invoke(ClosePopupUiEvent evt) { - if (_screenUIs.TryGetValue(evt.UiType, out var popUp)) + if (_screenUIs.TryGetValue(evt.UiType, out var popup)) { - popUp.Close(); + popup.Close(); - if (popUp.IsBlockingTime) + if (popup.IsBlockingTime) { - EventBus.Broadcast(new TimeScaleChangeEvent(popUp, 1f)); + var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent; + timeScaleChangeEvent.Requester = popup; + timeScaleChangeEvent.NewTimeScale = 1f; + EventBus.Broadcast(timeScaleChangeEvent); } } }