게임 이벤트 정적으로 변경
This commit is contained in:
parent
7319ee8541
commit
e8a7e1c289
@ -20,6 +20,5 @@ MonoBehaviour:
|
|||||||
- {fileID: 6471498998539637564, guid: fa2ad62c75b1549f09597e47ed5f7cfb, type: 3}
|
- {fileID: 6471498998539637564, guid: fa2ad62c75b1549f09597e47ed5f7cfb, type: 3}
|
||||||
- {fileID: 7665229218737596710, guid: 71b177c2a18314c588da30429451666a, type: 3}
|
- {fileID: 7665229218737596710, guid: 71b177c2a18314c588da30429451666a, type: 3}
|
||||||
- {fileID: 622422277636247943, guid: d95124918e5a4a246abb0d378b14d3fa, type: 3}
|
- {fileID: 622422277636247943, guid: d95124918e5a4a246abb0d378b14d3fa, type: 3}
|
||||||
- {fileID: 5136368050551183548, guid: 0aa6654feb91ef040b8b99d4f64688fc, type: 3}
|
|
||||||
- {fileID: 5539371897028506726, guid: 21cff8c1505cd8041a474795e35e0192, type: 3}
|
- {fileID: 5539371897028506726, guid: 21cff8c1505cd8041a474795e35e0192, type: 3}
|
||||||
- {fileID: 8500549904376788358, guid: d81cf4649bf54485a8b0da7a235f3817, type: 3}
|
- {fileID: 8500549904376788358, guid: d81cf4649bf54485a8b0da7a235f3817, type: 3}
|
||||||
|
@ -4,16 +4,25 @@
|
|||||||
|
|
||||||
namespace DDD
|
namespace DDD
|
||||||
{
|
{
|
||||||
// public static class GameEvents
|
public static class GameEvents
|
||||||
// {
|
{
|
||||||
// public static RequestTimeScaleChangeEvent RequestTimeScaleChangeEvent = new();
|
public static TimeScaleChangeEvent RequestTimeScaleChangeEvent = new();
|
||||||
// public static RequestShowGlobalMessageEvent RequestShowGlobalMessageEvent = new();
|
public static FadeInEvent FadeInEvent = new();
|
||||||
// public static InteractionEvent Interaction = new InteractionEvent();
|
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
|
// public static class RestaurantEvents
|
||||||
// {
|
// {
|
||||||
// // Some events...
|
// // Some events...
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// public static class VoyageEvents
|
// public static class VoyageEvents
|
||||||
// {
|
// {
|
||||||
// // Some events...
|
// // Some events...
|
||||||
@ -21,82 +30,51 @@ namespace DDD
|
|||||||
|
|
||||||
public class TimeScaleChangeEvent : IEvent
|
public class TimeScaleChangeEvent : IEvent
|
||||||
{
|
{
|
||||||
public readonly object Requester;
|
public object Requester;
|
||||||
public readonly float NewTimeScale;
|
public float NewTimeScale;
|
||||||
|
|
||||||
public TimeScaleChangeEvent(object requester, float newTimeScale)
|
|
||||||
{
|
|
||||||
Requester = requester;
|
|
||||||
NewTimeScale = newTimeScale;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FadeInEvent : IEvent
|
public class FadeInEvent : IEvent
|
||||||
{
|
{
|
||||||
public readonly float Duration;
|
public float Duration;
|
||||||
public readonly TaskCompletionSource<bool> CompletionSource;
|
public TaskCompletionSource<bool> CompletionSource;
|
||||||
|
|
||||||
public FadeInEvent(float duration)
|
|
||||||
{
|
|
||||||
Duration = duration;
|
|
||||||
CompletionSource = new TaskCompletionSource<bool>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task WaitAsync() => CompletionSource.Task;
|
public Task WaitAsync() => CompletionSource.Task;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FadeOutEvent : IEvent
|
public class FadeOutEvent : IEvent
|
||||||
{
|
{
|
||||||
public readonly float Duration;
|
public float Duration;
|
||||||
public readonly TaskCompletionSource<bool> CompletionSource;
|
public TaskCompletionSource<bool> CompletionSource;
|
||||||
|
|
||||||
public FadeOutEvent(float duration)
|
|
||||||
{
|
|
||||||
Duration = duration;
|
|
||||||
CompletionSource = new TaskCompletionSource<bool>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task WaitAsync() => CompletionSource.Task;
|
public Task WaitAsync() => CompletionSource.Task;
|
||||||
public static InventoryChangedEvent InventoryChangedEvent = new();
|
|
||||||
public static InteractionEvent Interaction = new();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ShowGlobalMessageEvent : IEvent
|
public class ShowGlobalMessageEvent : IEvent
|
||||||
{
|
{
|
||||||
public readonly string NewMessageKey;
|
public string NewMessageKey;
|
||||||
public readonly float ShowDuration;
|
public float ShowDuration;
|
||||||
public readonly float FadeDuration;
|
public float FadeDuration;
|
||||||
|
|
||||||
public ShowGlobalMessageEvent(string newMessageKey, float showDuration = 3f, float fadeDuration = 0.3f)
|
|
||||||
{
|
|
||||||
NewMessageKey = newMessageKey;
|
|
||||||
ShowDuration = showDuration;
|
|
||||||
FadeDuration = fadeDuration;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OpenScreenUiEvent : IEvent
|
public class OpenScreenUiEvent : IEvent
|
||||||
{
|
{
|
||||||
public readonly Type UiType;
|
public Type UiType;
|
||||||
public OpenScreenUiEvent(Type uiType) => UiType = uiType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CloseScreenUiEvent : IEvent
|
public class CloseScreenUiEvent : IEvent
|
||||||
{
|
{
|
||||||
public readonly Type UiType;
|
public Type UiType;
|
||||||
public CloseScreenUiEvent(Type uiType) => UiType = uiType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OpenPopupUiEvent : IEvent
|
public class OpenPopupUiEvent : IEvent
|
||||||
{
|
{
|
||||||
public readonly Type UiType;
|
public Type UiType;
|
||||||
public OpenPopupUiEvent(Type uiType) => UiType = uiType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ClosePopupUiEvent : IEvent
|
public class ClosePopupUiEvent : IEvent
|
||||||
{
|
{
|
||||||
public readonly Type UiType;
|
public Type UiType;
|
||||||
public ClosePopupUiEvent(Type uiType) => UiType = uiType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InteractionEvent : IEvent
|
public class InteractionEvent : IEvent
|
||||||
|
@ -17,7 +17,8 @@ public class FadeSceneTransitionHandlerSo : SceneTransitionHandler
|
|||||||
|
|
||||||
public override async Task OnBeforeSceneActivate(SceneType sceneType)
|
public override async Task OnBeforeSceneActivate(SceneType sceneType)
|
||||||
{
|
{
|
||||||
var evt = new FadeOutEvent(_fadeOutDuration);
|
var evt = GameEvents.FadeOutEvent;
|
||||||
|
evt.Duration = _fadeOutDuration;
|
||||||
EventBus.Broadcast(evt);
|
EventBus.Broadcast(evt);
|
||||||
await evt.WaitAsync();
|
await evt.WaitAsync();
|
||||||
}
|
}
|
||||||
@ -26,8 +27,9 @@ public override async Task OnAfterSceneActivate(SceneType sceneType)
|
|||||||
{
|
{
|
||||||
float seconds = _delayBeforeFadeIn * 1000;
|
float seconds = _delayBeforeFadeIn * 1000;
|
||||||
await Task.Delay((int)(seconds));
|
await Task.Delay((int)(seconds));
|
||||||
|
|
||||||
var evt = new FadeInEvent(_fadeInDuration);
|
var evt = GameEvents.FadeInEvent;
|
||||||
|
evt.Duration = _fadeInDuration;
|
||||||
EventBus.Broadcast(evt);
|
EventBus.Broadcast(evt);
|
||||||
await evt.WaitAsync();
|
await evt.WaitAsync();
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,10 @@ private void CloseAllScreenUIs()
|
|||||||
|
|
||||||
if (screen.IsBlockingTime)
|
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)
|
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)
|
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)
|
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)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user