順番待ちを修正/再陳列時の表示を改善/お客さんのタップを改善
This commit is contained in:
parent
1919152687
commit
38ebc2010c
|
|
@ -150,7 +150,7 @@ public class Market : MonoBehaviour
|
|||
}).AddTo(customerController);
|
||||
}).AddTo(this);
|
||||
|
||||
requestSubject.BatchFrame(30, FrameCountType.Update).Subscribe(customers =>
|
||||
requestSubject.BatchFrame().Subscribe(customers =>
|
||||
{
|
||||
if (gameData.ShopStock.Count == 0)
|
||||
{
|
||||
|
|
@ -161,7 +161,6 @@ public class Market : MonoBehaviour
|
|||
var dontBuyCustomerList = new List<CustomerController>();
|
||||
foreach (var controller in customers)
|
||||
{
|
||||
Debug.Log(shuffledOrder.Aggregate("", (s, i) => $"{s},{i}"));
|
||||
// 売り切れ
|
||||
if (shuffledOrder.Count == 0)
|
||||
{
|
||||
|
|
@ -192,6 +191,10 @@ public class Market : MonoBehaviour
|
|||
|
||||
// 購入
|
||||
var flavors = orders.Select(x => (displayFlavors[x], 0)).ToList();
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log($"bb order: {orders.Count} {orders.Aggregate("", (s, i) => $"{s},{i}")}");
|
||||
Debug.Log($"bb shuffledOrder:{shuffledOrder.Count} {shuffledOrder.Aggregate("", (s, i) => $"{s},{i}")}");
|
||||
#endif
|
||||
coin += SellPopcorn(flavors);
|
||||
var remainStockCount = gameData.ShopStock.Count;
|
||||
|
||||
|
|
@ -204,7 +207,6 @@ public class Market : MonoBehaviour
|
|||
if (gameData.ShopStock.Count == ShopStockCount)
|
||||
{
|
||||
shuffledOrder.AddRange(orders);
|
||||
Debug.Log($"remain {remainStockCount}, order {orders.Count}");
|
||||
var stock = gameData.ShopStock.GetRange(remainStockCount, orders.Count).ToArray();
|
||||
for (int i = 0; i < orders.Count; i++)
|
||||
{
|
||||
|
|
@ -230,6 +232,7 @@ public class Market : MonoBehaviour
|
|||
{
|
||||
cartView.SellStock(order);
|
||||
}
|
||||
|
||||
blueView.SellAction();
|
||||
// コイン獲得
|
||||
CoinManager.Instance.AddCoinWithEffect(coin, () => { });
|
||||
|
|
@ -261,7 +264,26 @@ public class Market : MonoBehaviour
|
|||
}
|
||||
else if (setStockFlag)
|
||||
{
|
||||
cartView.SetStock(displayFlavors);
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log($"bb setStockFlag {displayFlavors.Count} {shuffledOrder.Count}");
|
||||
#endif
|
||||
// 陳列
|
||||
cartView.ResetDisplay();
|
||||
for (int i = 0; i < displayFlavors.Count; i++)
|
||||
{
|
||||
var index = i;
|
||||
this.CallWaitForSeconds(.05f * i, () =>
|
||||
{
|
||||
if (!shuffledOrder.Contains(index))
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log($"bb no refill");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
cartView.Refill(index, displayFlavors[index]);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -340,19 +362,28 @@ public class Market : MonoBehaviour
|
|||
}
|
||||
}).AddTo(customerController);
|
||||
|
||||
var customerObject = customer.transform.GetChild(0).gameObject;
|
||||
if (x.isCustomer)
|
||||
{
|
||||
// 購入客リスト追加
|
||||
customerList.Add(customerController);
|
||||
if (customerObject.TryGetComponent(typeof(Collider2D), out var target))
|
||||
{
|
||||
Destroy(target);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 歩行者はタップ後購入客
|
||||
customerController.ChangeCustomerState(CustomerState.Walk);
|
||||
var eventTrigger = customer.transform.GetChild(0).gameObject.AddComponent<ObservableEventTrigger>();
|
||||
var eventTrigger = customerObject.AddComponent<ObservableEventTrigger>();
|
||||
eventTrigger.OnPointerClickAsObservable().Take(1).Subscribe(_ =>
|
||||
{
|
||||
customerList.Add(customerController);
|
||||
if (customerObject.TryGetComponent(typeof(Collider2D), out var target))
|
||||
{
|
||||
Destroy(target);
|
||||
}
|
||||
}).AddTo(customerController);
|
||||
}
|
||||
}).AddTo(this);
|
||||
|
|
@ -366,7 +397,6 @@ public class Market : MonoBehaviour
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
Debug.Log($"sellCount:{flavors.Count} {shuffledOrder.Count}");
|
||||
|
||||
// フレーバーを売る
|
||||
var coin = 0;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ public class MarketCartView : MonoBehaviour
|
|||
{
|
||||
[SerializeField] private List<MarketPopcornView> popcornPositions;
|
||||
|
||||
private void ResetDisplay()
|
||||
public void ResetDisplay()
|
||||
{
|
||||
foreach (var popcorn in popcornPositions)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue