diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs index ecaee574..80fb06c2 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs @@ -179,16 +179,15 @@ public class ProductManagement : MonoBehaviour tankList[index].SetState(TankState.Selected); var tankData = gameData.StorageTanks[index]; - selectedTank.Value = (tankList[index].TankNumber, productList.FirstOrDefault(data => data.id == tankData.FlavorId)); - Action tastingAction = () => + selectedTank.Value = (index + 1, productList.FirstOrDefault(data => data.id == tankData.FlavorId)); + void TastingAction() { state.Value = ManagementState.None; Tasting(selectedTank.Value.num); tankList[selectedTank.Value.num - 1].SetData(gameData.StorageTanks[selectedTank.Value.num - 1]); SetActiveTastingButton(gameData.StorageTanks.Any(tank => !tank.IsEmpty)); - }; - LocalCacheManager.Save(TastingView.TastingDataTag, (selectedTank.AsObservable(), new Action(() => state.Value = ManagementState.None), tastingAction)); - TransitionManager.Instance.LoadSceneAdditive(GameScenes.Tasting); + } + TastingView.ShowDialog(selectedTank.AsObservable(), () => state.Value = ManagementState.None, TastingAction); break; default: throw new ArgumentOutOfRangeException(nameof(mState), mState, null); diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingView.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingView.cs index 1a02c385..8653b887 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingView.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingView.cs @@ -6,7 +6,7 @@ using UnityEngine.UI; public class TastingView : MonoBehaviour { - public static readonly string TastingDataTag = "TastingData"; + private static readonly string TastingDataTag = "TastingData"; private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger"); private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger"); @@ -44,4 +44,10 @@ public class TastingView : MonoBehaviour }); }).AddTo(this); } + + public static void ShowDialog(IObservable<(int tankNum, ProductData productData)> selectedObservable, Action closeButtonAction, Action tastingButtonAction) + { + LocalCacheManager.Save(TastingDataTag, (selectedObservable, closeButtonAction, tastingButtonAction)); + TransitionManager.Instance.LoadSceneAdditive(GameScenes.Tasting); + } } \ No newline at end of file