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