ポップコーン販売数の保存処理追加

This commit is contained in:
kimura 2021-10-01 14:14:08 +09:00
parent 85709df1b1
commit 02ba3c8c68
1 changed files with 11 additions and 8 deletions

View File

@ -139,7 +139,7 @@ public class Market : MonoBehaviour
{ {
shopState.Value = ShopState.Close; shopState.Value = ShopState.Close;
} }
var coin = 0;
var orders = new List<int>(); var orders = new List<int>();
var dontBuyCustomerList = new List<CustomerController>(); var dontBuyCustomerList = new List<CustomerController>();
foreach (var controller in customers) foreach (var controller in customers)
@ -178,12 +178,12 @@ public class Market : MonoBehaviour
} }
// 購入 // 購入
var flavors = orders.Select(x => (displayFlavors[x], 0)).ToList(); var flavors = orders.Select(x => (displayFlavors[x], ProductRarity.Normal)).ToList();
#if UNITY_EDITOR #if UNITY_EDITOR
Debug.Log($"bb order: {orders.Count} {orders.Aggregate("", (s, i) => $"{s},{i}")}"); Debug.Log($"bb order: {orders.Count} {orders.Aggregate("", (s, i) => $"{s},{i}")}");
Debug.Log($"bb shuffledOrder:{shuffledOrder.Count} {shuffledOrder.Aggregate("", (s, i) => $"{s},{i}")}"); Debug.Log($"bb shuffledOrder:{shuffledOrder.Count} {shuffledOrder.Aggregate("", (s, i) => $"{s},{i}")}");
#endif #endif
coin += SellPopcorn(flavors); var coin = SellPopcorn(flavors);
var remainStockCount = gameData.ShopStock.Count; var remainStockCount = gameData.ShopStock.Count;
// 自動補充 refill // 自動補充 refill
@ -457,7 +457,7 @@ public class Market : MonoBehaviour
}).AddTo(this); }).AddTo(this);
} }
private int SellPopcorn(List<(int flavor, int bonusRate)> flavors) private int SellPopcorn(List<(int flavor, ProductRarity rarity)> flavors)
{ {
var gameData = GameDataManager.GameData; var gameData = GameDataManager.GameData;
// 品切れ // 品切れ
@ -467,14 +467,17 @@ public class Market : MonoBehaviour
} }
// フレーバーを売る // フレーバーを売る
var recipeList = RecipeData.GetAllRecipe();
var rarityList = SpreadsheetDataManager.Instance.GetBaseDataList<RarityData>(Const.RarityDataSheet);
var coin = 0; var coin = 0;
foreach (var flavorData in flavors) foreach (var flavorData in flavors)
{ {
var targetIndex = gameData.ShopStock.FindIndex(x => x == flavorData.flavor); var targetIndex = gameData.ShopStock.FindIndex(x => x == flavorData.flavor);
var flavorRecipe = RecipeData.GetAllRecipe().First(x => x.RecipeId == gameData.ShopStock[targetIndex]); var flavorRecipe = recipeList.First(data => data.RecipeId == gameData.ShopStock[targetIndex]);
var rarityData = rarityList.First(data => data.Rarity == flavorData.rarity);
gameData.ShopStock.RemoveAt(targetIndex); gameData.ShopStock.RemoveAt(targetIndex);
var bonusRate = 0; gameData.AddSalesCount(flavorData.flavor, 1, flavorData.rarity);
coin += flavorRecipe.Price * (1 + bonusRate / 100); coin += flavorRecipe.Price * (1 + rarityData.rate / 100);
} }
return coin; return coin;
} }