diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomize.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomize.cs index 714391bf..67a49d12 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomize.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomize.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using UniRx; using UnityEngine; @@ -80,5 +81,42 @@ namespace MyGame.Scenes.marketing.Scripts } } } + + private void PurchaseItem(ShopCustomizeData customizeData) + { + var gameData = GameDataManager.GameData; + gameData.ShopCustomizeCoin -= customizeData.price; + gameData.ShopCustomizePoint += customizeData.point; + gameData.MyRecipes = gameData.MyRecipes.Append(customizeData.id).ToArray(); + + var customizeLevelList = SpreadsheetDataManager.Instance.GetBaseDataList(Const.ShopCustomizeLevelDataSheet); + 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) + { + var customizeBonusList = SpreadsheetDataManager.Instance.GetBaseDataList(Const.ShopCustomizeBonusDataSheet); + var categories = (ShopCustomizeBonusCategory[])Enum.GetValues(typeof(ShopCustomizeBonusCategory)); + var list = new List<(ShopCustomizeBonusCategory, (int, int))>(); + foreach (var category in categories) + { + if (!(customizeBonusList.LastOrDefault(data => data.level <= level) is ShopCustomizeBonusData bonusData)) + { + bonusData = new ShopCustomizeBonusData() + { + bonusLevel = 0, + value = 0, + }; + } + list.Add((category, (bonusData.bonusLevel, bonusData.value))); + } + return list; + } } } \ No newline at end of file