diff --git a/nekoyume/Assets/_Scripts/UI/Widget/StageInformation.cs b/nekoyume/Assets/_Scripts/UI/Widget/StageInformation.cs index cc7f9b423d..1733236ac6 100644 --- a/nekoyume/Assets/_Scripts/UI/Widget/StageInformation.cs +++ b/nekoyume/Assets/_Scripts/UI/Widget/StageInformation.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using Cysharp.Threading.Tasks; using Nekoyume.ApiClient; using Nekoyume.Battle; using Nekoyume.EnumType; @@ -73,6 +74,16 @@ protected override void Awake() CloseWidget = OnClickClose; } + protected override void OnDisable() + { + base.OnDisable(); + var worldMap = Find(); + if (worldMap.gameObject.activeSelf) + { + worldMap.UpdateAssets(); + } + } + public override void Initialize() { base.Initialize(); @@ -126,11 +137,13 @@ private void RefreshSeasonPassCourageAmount(bool isEventDungeon = false) var expAmount = 0; if (isEventDungeon) { - expAmount = seasonPassServiceManager.ExpPointAmount(SeasonPassServiceClient.PassType.CouragePass, SeasonPassServiceClient.ActionType.event_dungeon); + expAmount = seasonPassServiceManager.ExpPointAmount(SeasonPassServiceClient.PassType.CouragePass, + SeasonPassServiceClient.ActionType.event_dungeon); } else { - expAmount = seasonPassServiceManager.ExpPointAmount(SeasonPassServiceClient.PassType.CouragePass, SeasonPassServiceClient.ActionType.hack_and_slash); + expAmount = seasonPassServiceManager.ExpPointAmount(SeasonPassServiceClient.PassType.CouragePass, + SeasonPassServiceClient.ActionType.hack_and_slash); } seasonPassCourageAmount.text = $"+{expAmount}"; } diff --git a/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs b/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs index 25c499a542..7b009c6425 100644 --- a/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs +++ b/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs @@ -161,7 +161,7 @@ public override void Initialize() public void Show(WorldInformation worldInformation, bool blockWorldUnlockPopup = false) { - SubscribeAtShow(); + UpdateAssets(); HasNotification = false; SetWorldInformation(worldInformation); @@ -180,22 +180,14 @@ public void Show(WorldInformation worldInformation, bool blockWorldUnlockPopup = public void Show(int worldId, int stageId, bool showWorld, bool callByShow = false) { - SubscribeAtShow(); ShowWorld(worldId, stageId, showWorld, callByShow); Show(true); Find().Show(); } - private void SubscribeAtShow() + public void UpdateAssets(bool isForceSetBattle = false) { _disposablesAtShow.DisposeAllAndClear(); - OnDisableStaticObservable - .Where(widget => widget is StageInformation) - .DelayFrame(1) - .Where(_ => gameObject.activeSelf) - .Subscribe(_ => SubscribeAtShow()) - .AddTo(_disposablesAtShow); - TextMeshProUGUI eventDungeonRemainingTimeText = null; RxProps.EventScheduleRowForDungeon.Subscribe(value => { foreach (var eventDungeonObject in eventDungeonObjects) @@ -204,7 +196,7 @@ private void SubscribeAtShow() eventDungeonObject.remainingTimeObject.SetActive(false); } - if (value is null) + if (isForceSetBattle || value is null) { Find() .UpdateAssets(HeaderMenuStatic.AssetVisibleState.Battle); @@ -221,15 +213,17 @@ private void SubscribeAtShow() eventDungeonObject.button.HasNotification.Value = true; eventDungeonObject.button.Unlock(); eventDungeonObject.remainingTimeObject.SetActive(true); - eventDungeonRemainingTimeText = eventDungeonObject.remainingTimeText; + + if (eventDungeonObject.remainingTimeText == null) + { + return; + } + + RxProps.EventDungeonRemainingTimeText + .SubscribeTo(eventDungeonObject.remainingTimeText) + .AddTo(_disposablesAtShow); } }).AddTo(_disposablesAtShow); - if (eventDungeonRemainingTimeText != null) - { - RxProps.EventDungeonRemainingTimeText - .SubscribeTo(eventDungeonRemainingTimeText) - .AddTo(_disposablesAtShow); - } } public override void Close(bool ignoreCloseAnimation = false) @@ -343,7 +337,6 @@ private void ShowWorld( SharedViewModel.IsWorldShown.SetValueAndForceNotify(showWorld); } - SubscribeAtShow(); TableSheets.Instance.WorldSheet.TryGetValue( worldId, @@ -354,7 +347,7 @@ private void ShowWorld( var stageInfo = Find(); stageInfo.Show(SharedViewModel, worldRow, StageType.HackAndSlash); UpdateNotificationInfo(); - Find().UpdateAssets(HeaderMenuStatic.AssetVisibleState.Battle); + UpdateAssets(true); Find().Show(); } @@ -372,8 +365,6 @@ public void ShowEventDungeonStage( SharedViewModel.IsWorldShown.SetValueAndForceNotify(showWorld); } - SubscribeAtShow(); - Show(true); var openedStageId = RxProps.EventDungeonInfo.Value is null || @@ -391,7 +382,7 @@ RxProps.EventDungeonInfo.Value is null || openedStageId, openedStageId); StageIdToNotify = openedStageId; - Find().UpdateAssets(HeaderMenuStatic.AssetVisibleState.EventDungeon); + UpdateAssets(); Find().Show(); }