Marketを設定クラスに対応
This commit is contained in:
parent
594a285814
commit
cb6601de8a
|
|
@ -46,7 +46,7 @@ public class Title : MonoBehaviour
|
||||||
.Subscribe(t =>
|
.Subscribe(t =>
|
||||||
{
|
{
|
||||||
// 一般客orセレブ
|
// 一般客orセレブ
|
||||||
var (isSpecial, orderCount) = Market.GetCustomerData(false);
|
var (isSpecial, orderCount) = Market.Instance.GetCustomerData(false);
|
||||||
|
|
||||||
// 複数パターンある場合ChooseRandom
|
// 複数パターンある場合ChooseRandom
|
||||||
var prefab = isSpecial ? customerData.ChooseSpecialPrefab() : customerData.ChooseNormalPrefab();
|
var prefab = isSpecial ? customerData.ChooseSpecialPrefab() : customerData.ChooseNormalPrefab();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MyGame.Scenes.marketing.Scripts;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UniRx;
|
using UniRx;
|
||||||
using UniRx.Triggers;
|
using UniRx.Triggers;
|
||||||
|
|
@ -18,21 +19,15 @@ public enum ShopState
|
||||||
public class Market : SingletonMonoBehaviour<Market>
|
public class Market : SingletonMonoBehaviour<Market>
|
||||||
{
|
{
|
||||||
public static readonly int ShopStockCount = 20;
|
public static readonly int ShopStockCount = 20;
|
||||||
private static readonly int SpecialOrderCount = 5;
|
|
||||||
private static readonly (int want, float weight)[] CustomerWeightTable = {
|
// 購入時アニメーションタイミング
|
||||||
(1, 75f),
|
private static readonly float waitSellTime = 1.5f;
|
||||||
(2, 15f),
|
private static readonly float waitRefillTime = 1f;
|
||||||
(3, 3.5f),
|
|
||||||
(4, 1.25f),
|
|
||||||
(5, .25f),
|
|
||||||
(0, 5f),
|
|
||||||
};
|
|
||||||
private static readonly float walkerSpecialRate = .01f;
|
|
||||||
private static readonly float customerSpecialRate = .01f;
|
|
||||||
|
|
||||||
[SerializeField] private CustomerFlow customerFlow;
|
[SerializeField] private CustomerFlow customerFlow;
|
||||||
[SerializeField] private GameObject orderPosisionObject;
|
[SerializeField] private GameObject orderPosisionObject;
|
||||||
[SerializeField] private CustomerData customerData;
|
[SerializeField] private CustomerData customerData;
|
||||||
|
[SerializeField] private CustomerSetting customerSetting;
|
||||||
[SerializeField] private CustomerController customerControllerPrefab;
|
[SerializeField] private CustomerController customerControllerPrefab;
|
||||||
|
|
||||||
public List<ProductStockData> DisplayFlavors => displayFlavors;
|
public List<ProductStockData> DisplayFlavors => displayFlavors;
|
||||||
|
|
@ -229,13 +224,13 @@ public class Market : SingletonMonoBehaviour<Market>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.CallWaitForSeconds(1.5f, () =>
|
this.CallWaitForSeconds(waitSellTime, () =>
|
||||||
{
|
{
|
||||||
sellObservable.OnNext(coin);
|
sellObservable.OnNext(coin);
|
||||||
sellOrderSubject.OnNext(orders);
|
sellOrderSubject.OnNext(orders);
|
||||||
CheckStock(gameData.ShopStock);
|
CheckStock(gameData.ShopStock);
|
||||||
|
|
||||||
this.CallWaitForSeconds(1f, () =>
|
this.CallWaitForSeconds(waitRefillTime, () =>
|
||||||
{
|
{
|
||||||
refillSubject.OnNext((isReorder, refillList));
|
refillSubject.OnNext((isReorder, refillList));
|
||||||
foreach (var controller in customers)
|
foreach (var controller in customers)
|
||||||
|
|
@ -341,28 +336,9 @@ public class Market : SingletonMonoBehaviour<Market>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static (bool isSpecial, int orderCount) GetCustomerData (bool isCustomer)
|
public (bool isSpecial, int orderCount) GetCustomerData (bool isCustomer)
|
||||||
{
|
{
|
||||||
var specialRate = isCustomer ? walkerSpecialRate : customerSpecialRate;
|
return customerSetting.GetCustomerData(isCustomer);
|
||||||
var isSpecial = Random.value < specialRate;
|
|
||||||
|
|
||||||
// セレブは5個購入固定
|
|
||||||
return isSpecial ? (true, specialOrderCount: SpecialOrderCount) : (false, GetOrderCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
// お客さん出現パターン確率計算と行動パターン計算
|
|
||||||
private static int GetOrderCount()
|
|
||||||
{
|
|
||||||
var randomPoint = Random.value * CustomerWeightTable.Sum(x => x.weight);
|
|
||||||
foreach (var value in CustomerWeightTable)
|
|
||||||
{
|
|
||||||
if (randomPoint < value.weight)
|
|
||||||
{
|
|
||||||
return value.want;
|
|
||||||
}
|
|
||||||
randomPoint -= value.weight;
|
|
||||||
}
|
|
||||||
return CustomerWeightTable.Last().want;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CustomerController SpawnCustomer()
|
private CustomerController SpawnCustomer()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue