diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs index 16d4c56c..878e41dd 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs @@ -46,8 +46,6 @@ public class BulkOrder : MonoBehaviour }).AddTo(this); var gameData = GameDataManager.GameData; - // キャンセルすると試食と同じ扱い - // 試食時のお客さんの増加ってどれくらいなんだろ var bulkOrderList = SpreadsheetDataManager.Instance.GetBaseDataList(Const.BulkOrderDataSheet); var messageList = SpreadsheetDataManager.Instance.GetBaseDataList(Const.BulkOrderTextDataSheet); var bulkOrderData = bulkOrderList.First(data => data.id == gameData.OrderIdInProgress); @@ -61,7 +59,19 @@ public class BulkOrder : MonoBehaviour { LocalCacheManager.Save(CancelCallbackTag, new Action(() => { - // 試食フラグ + // 試食数追加 + if (gameData.CompletedProductList.Exists(data => data.Number == 1)) + { + gameData.AddTastingCustomerCount(bulkOrderData.count1); + } + else if (gameData.CompletedProductList.Exists(data => data.Number == 2)) + { + gameData.AddTastingCustomerCount(bulkOrderData.count2); + } + else if (gameData.CompletedProductList.Exists(data => data.Number == 3)) + { + gameData.AddTastingCustomerCount(bulkOrderData.count3); + } gameData.CancelOrderId = gameData.OrderIdInProgress; // カウントリセット gameData.OrderConditionCount = 0; diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs index 802a7b72..3c2edc31 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs @@ -9,11 +9,14 @@ public class CustomerFlow : MonoBehaviour private IObservable walkerObservable; private IObservable adWalkerObservable; private readonly Subject> adStartObservable = new Subject>(); + private IObservable tastingCustomerObservable; private static readonly float checkHeartInterval = 1f; // 歩行者の出現間隔 private static readonly float walkerInterval = 60f / 6; + // 試食で来るお客さん間隔 + private static readonly float tastingCustomerInterval = 5f; - public IObservable Flow => walkerObservable.Merge(customerObservable, adWalkerObservable); + public IObservable Flow => walkerObservable.Merge(customerObservable, adWalkerObservable, tastingCustomerObservable); private void Awake() { @@ -32,15 +35,15 @@ public class CustomerFlow : MonoBehaviour // お客さん出現タイマー customerObservable = changeCustomerFlowObservable .DistinctUntilChanged() - .Do(x => Debug.Log($"changeInterval:{x}")) - .Select(customerInterval => Observable.Interval(TimeSpan.FromSeconds(customerInterval)) - .Do(_ => Debug.Log($"customer:{GetHashCode()}")) - .Select(_ => true)) - .Switch(); + // .Do(x => Debug.Log($"changeInterval:{x}")) + .Select(customerInterval => Observable.Interval(TimeSpan.FromSeconds(customerInterval))) + .Switch() + // .Do(_ => Debug.Log($"customer:{GetHashCode()}")) + .Select(_ => true); // 歩行者出現頻度、立ち止まり確率も設定(歩行者タイマー1分間に6人 walkerObservable = Observable.Interval(TimeSpan.FromSeconds(walkerInterval)) - .Do(l => Debug.Log($"walker:{GetHashCode()}")) + // .Do(l => Debug.Log($"walker:{GetHashCode()}")) .Select(x => false); // 宣伝時、タップすると60秒だけ稼働するストリーム @@ -54,6 +57,19 @@ public class CustomerFlow : MonoBehaviour // Observable.Timer(TimeSpan.FromSeconds(1f), TimeSpan.FromSeconds(70f)).Subscribe(_ => { adStartObservable.OnNext(default); }).AddTo(this); } #endif + // 試食 + var tastingTimer = Observable.Interval(TimeSpan.FromSeconds(tastingCustomerInterval)) + .Where(_ => GameDataManager.GameData.TastingCount > 0) + .Publish() + .RefCount(); + // 試食残りカウントを減らす + tastingTimer.Subscribe(_ => + { + GameDataManager.GameData.TastingCount--; + }); + tastingCustomerObservable = tastingTimer + // .Do(_ => Debug.Log($"tastingCustomer remain:{GameDataManager.GameData.TastingCount}")) + .Select(_ => true); } public void StartAdWalker(Action onComplete = null) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingView.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingView.cs index 02fbed26..eeb9d40c 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingView.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingView.cs @@ -14,7 +14,6 @@ public class TastingView : MonoBehaviour [SerializeField] private Button closeButton; [SerializeField] private Button tastingButton; [SerializeField] private Text popcornName; - [SerializeField] private Image popcornImage; [SerializeField] private Transform packageImageTarget; private void Start() diff --git a/popcorn/Assets/MyGame/Scripts/GameDataManager.cs b/popcorn/Assets/MyGame/Scripts/GameDataManager.cs index 7a6dd8fb..4d728563 100644 --- a/popcorn/Assets/MyGame/Scripts/GameDataManager.cs +++ b/popcorn/Assets/MyGame/Scripts/GameDataManager.cs @@ -98,8 +98,8 @@ public sealed class GameData { [DataMember(Name = "Data25")] private int[] achievedMission; public List AchievedMission; - // [DataMember(Name = "Data26")] - + [DataMember(Name = "Data26")] + public int TastingCount; // BulkOrder [DataMember(Name = "Data27")] @@ -188,6 +188,11 @@ public sealed class GameData { return TotalSalesList.Where(data => data.FlavorId == id).Sum(data => data.Stock); } + public void AddTastingCustomerCount(int value) + { + TastingCount += Mathf.FloorToInt(value / 2f); + } + // public void ChangeAvatar(AvatarData avatarData){ // newAvatarIdList.Remove(avatarData.id); // }