diff --git a/popcorn/Assets/MyGame/Scripts/GetRewardDialog.cs b/popcorn/Assets/MyGame/Scripts/GetRewardDialog.cs index 7d9302dc..538fa3f0 100644 --- a/popcorn/Assets/MyGame/Scripts/GetRewardDialog.cs +++ b/popcorn/Assets/MyGame/Scripts/GetRewardDialog.cs @@ -103,27 +103,35 @@ namespace MyGame.Scripts }).AddTo(this); okButton.OnClickAsObservable().Take(1).Subscribe(_ => { - if (AdManager.Instance.IsLoadedRewardVideo()) + ShowRewardVideo(GameScenes.WatchMovieCoin, Placement, () => { - AdManager.Instance.ShowRewardVideo(result => - { - if (result) - { - GameDataManager.GameData.AddAdCount(); - LocalCacheManager.Load(OkCallbackTag, null)?.Invoke(); - LocalCacheManager.Remove(OkCallbackTag); - } - TransitionManager.Instance.UnloadScene(GameScenes.WatchMovieCoin); - }, Placement); - } - else - { - TransitionManager.Instance.LoadSceneAdditive(GameScenes.WatchMovieFailure); - TransitionManager.Instance.UnloadScene(GameScenes.WatchMovieCoin); - } + LocalCacheManager.Load(OkCallbackTag, null)?.Invoke(); + LocalCacheManager.Remove(OkCallbackTag); + }); }).AddTo(this); } + public static void ShowRewardVideo(GameScenes unloadScene, string placement, Action successCallback) + { + if (AdManager.Instance.IsLoadedRewardVideo()) + { + AdManager.Instance.ShowRewardVideo(result => + { + if (result) + { + successCallback?.Invoke(); + GameDataManager.GameData.AddAdCount(); + } + TransitionManager.Instance.UnloadScene(unloadScene); + }, placement); + } + else + { + TransitionManager.Instance.LoadSceneAdditive(GameScenes.WatchMovieFailure); + TransitionManager.Instance.UnloadScene(unloadScene); + } + } + private static void ShowDialog(RewardType rewardType, Action okCallback, Action closeCallback) { LocalCacheManager.Save(OkCallbackTag, okCallback);