diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs index f123b44a..60b95341 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs @@ -23,6 +23,9 @@ public class CustomerFlow : MonoBehaviour [Header("試食のお客さん出現間隔(秒)")] [SerializeField] private float tastingCustomerInterval = 5f; + public float TastingCustomerInterval => tastingCustomerInterval; + private int adActiveCount = 0; + public IObservable Flow => walkerObservable.Merge(customerObservable, adWalkerObservable, tastingCustomerObservable); private void Awake() @@ -66,8 +69,11 @@ public class CustomerFlow : MonoBehaviour } #endif // 試食 + // tastingCustomerInterval毎にTastingCountを確認 var tastingTimer = Observable.Interval(TimeSpan.FromSeconds(tastingCustomerInterval)) - .Where(_ => GameDataManager.GameData.TastingCount > 0) + .Where(_ => adActiveCount <= 0) // 宣伝中判定 + .Where(_ => GameDataManager.GameData.ShopStock.Count > 0) // 在庫ゼロ判定 + .Where(_ => GameDataManager.GameData.TastingCount > 0) // 試食残り判定 .Publish() .RefCount(); // 試食残りカウントを減らす @@ -84,8 +90,10 @@ public class CustomerFlow : MonoBehaviour { var timerObservable = AdWalkerTimer().Publish().RefCount(); adStartObservable.OnNext(timerObservable); + adActiveCount++; timerObservable.Subscribe(_ => { }, () => { + adActiveCount--; onComplete?.Invoke(); }).AddTo(this); }