ボーナス取得処理を変更/ ボーナス更新処理を追加

This commit is contained in:
kimura 2022-05-16 18:48:34 +09:00
parent c13c5ee529
commit cb0f354301
2 changed files with 10 additions and 13 deletions

View File

@ -87,6 +87,7 @@ namespace MyGame.Scenes.marketing.Scripts
ShopCustomizePurchaseDialog.ShowDialog(customizeData, false, () =>
{
PurchaseItem(customizeData);
Market.Instance.UpdateBonus(GetBonusList(gameData.ShopCustomizeLevel));
selectSubject.OnNext(Unit.Default);
});
}).AddTo(this);
@ -112,28 +113,24 @@ namespace MyGame.Scenes.marketing.Scripts
var level = customizeLevelList.LastOrDefault(data => data.point <= gameData.ShopCustomizePoint)?.level ?? 1;
gameData.ShopCustomizeLevel = level;
GameDataManager.SaveGameData();
// update bonus
}
/*
*
*/
public static List<(ShopCustomizeBonusCategory category, (int bonusLevel, int value) bonusData)> GetBonusList(int level)
public static Dictionary<ShopCustomizeBonusCategory, (int bonusLevel, int value)> GetBonusList(int level)
{
var customizeBonusList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopCustomizeBonusData>(Const.ShopCustomizeBonusDataSheet);
var categories = (ShopCustomizeBonusCategory[])Enum.GetValues(typeof(ShopCustomizeBonusCategory));
var list = new List<(ShopCustomizeBonusCategory, (int, int))>();
var list = new Dictionary<ShopCustomizeBonusCategory, (int bonusLevel, int value)>();
foreach (var category in categories)
{
if (!(customizeBonusList.LastOrDefault(data => data.level <= level) is ShopCustomizeBonusData bonusData))
if (customizeBonusList.LastOrDefault(data => data.level <= level) is ShopCustomizeBonusData bonusData)
{
bonusData = new ShopCustomizeBonusData()
{
bonusLevel = 0,
value = 0,
};
list.Add(category, (bonusData.bonusLevel, bonusData.value));
continue;
}
list.Add((category, (bonusData.bonusLevel, bonusData.value)));
list.Add(category, (0, 0));
}
return list;
}

View File

@ -48,9 +48,9 @@ namespace MyGame.Scenes.marketing.Scripts
pointText.text = "--";
}
var list = ShopCustomize.GetBonusList(gameData.ShopCustomizeLevel);
var sales = list.FirstOrDefault(data => data.category == ShopCustomizeBonusCategory.Sales).bonusData.value;
var customer = list.FirstOrDefault(data => data.category == ShopCustomizeBonusCategory.Customer).bonusData.bonusLevel;
var adWalker = list.FirstOrDefault(data => data.category == ShopCustomizeBonusCategory.AdWalker).bonusData.bonusLevel;
var sales = list[ShopCustomizeBonusCategory.Sales].value;
var customer = list[ShopCustomizeBonusCategory.Customer].bonusLevel;
var adWalker = list[ShopCustomizeBonusCategory.AdWalker].bonusLevel;
salesBonusText.text = sales == 0 ? "--" : $"+{sales}";
customerBonusText.text = customer == 0 ? "--" : $"Lv.{customer}";
adWalkerBonusText.text = adWalker == 0 ? "--" : $"Lv.{adWalker}";