商品管理シーン表示中はお客さんの生成と動きを止める

This commit is contained in:
kimura 2021-10-15 19:50:57 +09:00
parent e54293dce9
commit 1448403674
3 changed files with 23 additions and 0 deletions

View File

@ -34,6 +34,7 @@ public class CustomerController : MonoBehaviour
public int OrderCount;
public CustomerAnimator CustomerPrefab;
public bool IsCustomer;
public bool IsPause;
// 歩道の幅(min,max)
[SerializeField] private float walkSideTopPosition;
@ -102,6 +103,10 @@ public class CustomerController : MonoBehaviour
}).AddTo(this);
this.UpdateAsObservable().Subscribe(_ =>
{
if (IsPause)
{
return;
}
var localPosition = transform.localPosition;
localPosition = Vector2.MoveTowards(localPosition, wayPoint, speed * Time.deltaTime);
localPosition = localPosition + Vector3.forward * (localPosition.y + Mathf.Abs(walkSideBottomPos));

View File

@ -38,6 +38,7 @@ public class Market : SingletonMonoBehaviour<Market>
private readonly Subject<CustomerController> requestSubject = new Subject<CustomerController>();
private readonly ReactiveCollection<CustomerController> waitCustomerList = new ReactiveCollection<CustomerController>();
private readonly Subject<Unit> orderSubject = new Subject<Unit>();
public readonly BoolReactiveProperty IsPause = new BoolReactiveProperty(false);
public Subject<int> SellObservable => sellObservable;
private readonly Subject<int> sellObservable = new Subject<int>();
@ -57,6 +58,7 @@ public class Market : SingletonMonoBehaviour<Market>
waitCustomerList.AddTo(this);
requestSubject.AddTo(this);
orderSubject.AddTo(this);
IsPause.AddTo(this);
var gameData = GameDataManager.GameData;
@ -247,6 +249,10 @@ public class Market : SingletonMonoBehaviour<Market>
customerFlow.Flow.Subscribe(isCustomer =>
{
if (IsPause.Value)
{
return;
}
// 一般客orセレブ
var (isSpecial, orderCount) = GetCustomerData(isCustomer);
@ -266,6 +272,11 @@ public class Market : SingletonMonoBehaviour<Market>
customerController.OrderCount = orderCount;
customerController.CustomerPrefab = prefab;
customerControllerList.Add(customerController);
IsPause.Subscribe(x =>
{
customerController.IsPause = x;
}).AddTo(customerController);
customerController.MoveEndObservable
.SkipLatestValueOnSubscribe()

View File

@ -22,6 +22,8 @@ public class ProductManagement : MonoBehaviour
{
state.AddTo(this);
state.Value = ManagementState.None;
Market.Instance.IsPause.Value = true;
var gameData = GameDataManager.GameData;
CoinManager.Instance.ChangeCoin(gameData.Coin);
HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart);
@ -269,4 +271,9 @@ public class ProductManagement : MonoBehaviour
GameDataManager.SaveGameData();
// 試食フラグに終了時間を設定
}
private void OnDestroy()
{
Market.Instance.IsPause.Value = false;
}
}