diff --git a/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs b/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs index 61be50474..cafd583ee 100644 --- a/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs +++ b/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs @@ -9,8 +9,6 @@ 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(); @@ -56,16 +54,6 @@ public class ShowGlobalMessageEvent : IEvent public float ShowDuration; public float FadeDuration; } - - public class OpenScreenUiEvent : IEvent - { - public Type UiType; - } - - public class CloseScreenUiEvent : IEvent - { - public Type UiType; - } public class OpenPopupUiEvent : IEvent { diff --git a/Assets/_DDD/_Scripts/GameUi/UiManager.cs b/Assets/_DDD/_Scripts/GameUi/UiManager.cs index 387d1d247..eaeccd36b 100644 --- a/Assets/_DDD/_Scripts/GameUi/UiManager.cs +++ b/Assets/_DDD/_Scripts/GameUi/UiManager.cs @@ -4,18 +4,14 @@ namespace DDD { - public class UiManager : Singleton, IManager, IEventHandler, IEventHandler, - IEventHandler, IEventHandler + public class UiManager : Singleton, IManager, IEventHandler, IEventHandler { - private readonly Dictionary _screenUIs = new(); private readonly Dictionary _popupUIs = new(); private readonly object _uiPauseRequester = new(); public void PreInit() { - EventBus.Register(this); - EventBus.Register(this); EventBus.Register(this); EventBus.Register(this); } @@ -32,27 +28,10 @@ public void PostInit() private void OnDestroy() { - EventBus.Unregister(this); - EventBus.Unregister(this); EventBus.Unregister(this); EventBus.Unregister(this); } - public void RegisterScreenUI(ScreenUi ui) - { - var type = ui.GetType(); - _screenUIs.TryAdd(type, ui); - } - - public void UnregisterScreenUI(ScreenUi ui) - { - var type = ui.GetType(); - if (_screenUIs.TryGetValue(type, out var value) && value == ui) - { - _screenUIs.Remove(type); - } - } - public void RegisterPopupUI(PopupUi ui) { var type = ui.GetType(); @@ -68,58 +47,6 @@ public void UnregisterPopupUI(PopupUi ui) } } - private void CloseAllScreenUIs() - { - foreach (var screen in _screenUIs.Values) - { - if (screen.IsOpen) - { - screen.Close(); - - if (screen.IsBlockingTime) - { - var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent; - timeScaleChangeEvent.Requester = _uiPauseRequester; - timeScaleChangeEvent.NewTimeScale = 1f; - EventBus.Broadcast(timeScaleChangeEvent); - } - } - } - } - - public void Invoke(OpenScreenUiEvent evt) - { - if (_screenUIs.TryGetValue(evt.UiType, out var screen)) - { - CloseAllScreenUIs(); - screen.Open(); - - if (screen.IsBlockingTime) - { - var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent; - timeScaleChangeEvent.Requester = screen; - timeScaleChangeEvent.NewTimeScale = 0f; - EventBus.Broadcast(timeScaleChangeEvent); - } - } - } - - public void Invoke(CloseScreenUiEvent evt) - { - if (_screenUIs.TryGetValue(evt.UiType, out var screen)) - { - screen.Close(); - - if (screen.IsBlockingTime) - { - var timeScaleChangeEvent = GameEvents.RequestTimeScaleChangeEvent; - timeScaleChangeEvent.Requester = screen; - timeScaleChangeEvent.NewTimeScale = 1f; - EventBus.Broadcast(timeScaleChangeEvent); - } - } - } - public void Invoke(OpenPopupUiEvent evt) { if (_popupUIs.TryGetValue(evt.UiType, out var popup)) @@ -138,7 +65,7 @@ public void Invoke(OpenPopupUiEvent evt) public void Invoke(ClosePopupUiEvent evt) { - if (_screenUIs.TryGetValue(evt.UiType, out var popup)) + if (_popupUIs.TryGetValue(evt.UiType, out var popup)) { popup.Close();