カスタマイズ機能購入処理追加/ボーナス情報取得処理追加

This commit is contained in:
kimura 2022-05-13 10:54:30 +09:00
parent 391f6a8d1b
commit a137e3e259
1 changed files with 38 additions and 0 deletions

View File

@ -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<ShopCustomizeLevelData>(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<ShopCustomizeBonusData>(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;
}
}
}