public InventoryCurrencyLookup(InventoryCurrency currency) : this(currency, 0) { }
public InventoryCurrencyLookup(InventoryCurrency currency, float startAmount) { _currencyID = currency.ID; _amount = startAmount; }
/// <summary> /// Grab the total factor of converting from a currency to another. /// For example copper to silver = 0.01 > silver to gold = 0.01 * 0.01 = 0.0001 /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> private float _GetConversionFactor(Dictionary<uint, float> dict, InventoryCurrency fromCurrency, float factor) { foreach (var lookup in parentContainer.lookups) { // Find currency that converts to our current currency. var convertToCurrent = lookup.currency.currencyConversions.FirstOrDefault(o => o.currencyID == fromCurrency.ID && o.useInAutoConversion); if (convertToCurrent != null) { if (dict.ContainsKey(lookup._currencyID)) { //Debug.Log("need update? factor: " + factor + " convertToCurrent factor: " + convertToCurrent.factor + " at " + lookup.currency.pluralName); } else { // One conversion higher factor /= convertToCurrent.factor; // Division because we're going the other way... dict.Add(lookup._currencyID, factor); return _GetConversionFactor(dict, lookup.currency, factor); } } } return factor; }