If anyone is having issues with using Ints instead of floats here… this is my code for it. (Quick note I use a slightly different style guide than he does… remove the underscores from private variables and the capital letter from LevelToUnlock and you will be fine)
private Dictionary<InventoryItem, int> GetAvailabilities()
{
Dictionary<InventoryItem, int> availabilities = new Dictionary<InventoryItem, int>();
foreach (var config in GetAvailableConfigs())
{
if (!availabilities.ContainsKey(config._item))
{
availabilities[config._item] = 0;
}
availabilities[config._item] += config._initialStock;
}
return availabilities;
}
private Dictionary<InventoryItem, int> GetPrices()
{
Dictionary<InventoryItem, int> prices = new Dictionary<InventoryItem, int>();
foreach (var config in GetAvailableConfigs())
{
if (!prices.ContainsKey(config._item))
{
prices[config._item] = config._item.GetPrice();
}
prices[config._item] = Mathf.CeilToInt(prices[config._item] * (1f - config._buyingDiscountPercentage / 100f));
}
return prices;
}
private IEnumerable<StockItemConfig> GetAvailableConfigs()
{
int shopperLevel = GetShopperLevel();
foreach (var config in _stockConfig)
{
if (config.LevelToUnlock > shopperLevel) continue;
yield return config;
}
}