ボーナス反映処理追加
This commit is contained in:
parent
65c5dc31af
commit
c13c5ee529
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
|
@ -19,7 +20,8 @@ public class CustomerFlow : MonoBehaviour
|
|||
private IObservable<CustomerType> vipCustomerObservable;
|
||||
private readonly Subject<IObservable<Unit>> vipCustomerSubject = new Subject<IObservable<Unit>>();
|
||||
private IObservable<CustomerType> tastingCustomerObservable;
|
||||
private static readonly float checkHeartInterval = 1f;
|
||||
private static readonly float CheckHeartInterval = 1f;
|
||||
private static readonly float TenMinutes = 60f * 10;
|
||||
|
||||
[Header("1分間あたりの歩行者数")]
|
||||
[SerializeField] private float walkerInterval = 60f / 6;
|
||||
|
|
@ -39,6 +41,9 @@ public class CustomerFlow : MonoBehaviour
|
|||
|
||||
public float TastingCustomerInterval => tastingCustomerInterval;
|
||||
private int adActiveCount = 0;
|
||||
// bonus
|
||||
private int customerBonus;
|
||||
private int adWalkerBonus;
|
||||
|
||||
public IObservable<CustomerType> Flow => walkerObservable.Merge(customerObservable, adWalkerObservable, vipCustomerObservable, tastingCustomerObservable);
|
||||
|
||||
|
|
@ -49,17 +54,15 @@ public class CustomerFlow : MonoBehaviour
|
|||
|
||||
var shopLevelList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopLevelData>(Const.ShopLevelDataSheet);
|
||||
shopLevelList = shopLevelList.Where(data => data.shopLevel != Const.SpecialShopLevel).ToList();
|
||||
// 10分間期待値を来客の間隔に変換
|
||||
var intervalList = shopLevelList.Select(shopLevel => (heart: shopLevel.heart, interval: 60f * 10 / shopLevel.customer));
|
||||
|
||||
// 1秒間隔でハートを確認
|
||||
var changeCustomerFlowObservable = Observable.Interval(TimeSpan.FromSeconds(checkHeartInterval))
|
||||
.Select(_ => GameDataManager.GameData.Heart)
|
||||
.DistinctUntilChanged()
|
||||
.Select(heart => intervalList.Last(x => x.heart <= heart).interval);
|
||||
|
||||
var changeCustomerFlowObservable = Observable.Interval(TimeSpan.FromSeconds(CheckHeartInterval))
|
||||
.Select(_ => GameDataManager.GameData.Heart);
|
||||
|
||||
// お客さん出現タイマー
|
||||
customerObservable = changeCustomerFlowObservable
|
||||
.DistinctUntilChanged()
|
||||
.Select(heart => TenMinutes / (shopLevelList.Last(x => x.heart <= heart).customer + customerBonus)) // 10分間期待値を来客の間隔に変換
|
||||
.DistinctUntilChanged()
|
||||
// .Do(x => Debug.Log($"changeInterval:{x}"))
|
||||
.Select(customerInterval => Observable.Interval(TimeSpan.FromSeconds(customerInterval)))
|
||||
|
|
@ -121,7 +124,7 @@ public class CustomerFlow : MonoBehaviour
|
|||
|
||||
private IObservable<Unit> AdWalkerTimer()
|
||||
{
|
||||
return Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(adWalkerDuration/adWalkerCount))
|
||||
return Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(adWalkerDuration/(adWalkerCount + adWalkerBonus)))
|
||||
.Take(TimeSpan.FromSeconds(adWalkerDuration))
|
||||
.AsUnitObservable();
|
||||
}
|
||||
|
|
@ -132,4 +135,10 @@ public class CustomerFlow : MonoBehaviour
|
|||
.Take(vipCustomerCount)
|
||||
.AsUnitObservable());
|
||||
}
|
||||
|
||||
public void UpdateBonus(Dictionary<ShopCustomizeBonusCategory, (int bonusLevel, int value)> bonusList)
|
||||
{
|
||||
customerBonus = bonusList[ShopCustomizeBonusCategory.Customer].value;
|
||||
adWalkerBonus = bonusList[ShopCustomizeBonusCategory.AdWalker].value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ public class Market : SingletonMonoBehaviour<Market>
|
|||
|
||||
private int orderIndex;
|
||||
private int oneByOneIndex = 0;
|
||||
private int salesBonus = 0;
|
||||
private GameData gameData;
|
||||
|
||||
// Start is called before the first frame update
|
||||
|
|
@ -442,6 +443,7 @@ public class Market : SingletonMonoBehaviour<Market>
|
|||
gameData.ShopStock.RemoveAt(targetIndex);
|
||||
gameData.AddSalesCount(stockData.FlavorId, 1, stockData.Rarity);
|
||||
coin += productData.GetRarityPrice(rarityData.Rarity);
|
||||
coin += salesBonus;
|
||||
}
|
||||
return coin;
|
||||
}
|
||||
|
|
@ -562,6 +564,13 @@ public class Market : SingletonMonoBehaviour<Market>
|
|||
customerFlow.StartVip();
|
||||
}
|
||||
|
||||
public void UpdateBonus(Dictionary<ShopCustomizeBonusCategory, (int bonusLevel, int value)> bonusList)
|
||||
{
|
||||
// sales
|
||||
salesBonus = bonusList[ShopCustomizeBonusCategory.Sales].value;
|
||||
customerFlow.UpdateBonus(bonusList);
|
||||
}
|
||||
|
||||
public CustomerController SetTutorialCustomer()
|
||||
{
|
||||
var customerController = SpawnCustomer();
|
||||
|
|
|
|||
Loading…
Reference in New Issue