public void BuyBackSoldItems(List <SoldItem> itemsToBuy) { foreach (SoldItem item in itemsToBuy) { var itemValue = GetSellValueAtCurrentLocation(item.ItemPrefab); if (location.StoreCurrentBalance < itemValue || item.Removed) { continue; } location.StoreCurrentBalance += itemValue; campaign.Money -= itemValue; SoldItems.Remove(item); } }
public void BuyBackSoldItems(List <SoldItem> itemsToBuy) { // Check all the prices before starting the transaction // to make sure the modifiers stay the same for the whole transaction Dictionary <ItemPrefab, int> sellValues = GetSellValuesAtCurrentLocation(itemsToBuy.Select(i => i.ItemPrefab)); foreach (SoldItem item in itemsToBuy) { var itemValue = sellValues[item.ItemPrefab]; if (Location.StoreCurrentBalance < itemValue || item.Removed) { continue; } Location.StoreCurrentBalance += itemValue; campaign.Money -= itemValue; SoldItems.Remove(item); } }