試食と宣伝の排他制御追加
This commit is contained in:
parent
922d9b898d
commit
9a3089a4f6
|
|
@ -23,6 +23,9 @@ public class CustomerFlow : MonoBehaviour
|
|||
[Header("試食のお客さん出現間隔(秒)")]
|
||||
[SerializeField] private float tastingCustomerInterval = 5f;
|
||||
|
||||
public float TastingCustomerInterval => tastingCustomerInterval;
|
||||
private int adActiveCount = 0;
|
||||
|
||||
public IObservable<bool> 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue