public void SubscribeToCurrencyChange(CurrencyType type, m.MonoActionInt callback, bool invokeOnSubscribe) { SubscribeToCurrencyChange(type, callback); if (invokeOnSubscribe) { callback(currencies[type].Amount); } }
public void UnsubscribeFromCurrencyChange(CurrencyType type, m.MonoActionInt callback) { m.MonoActionInt handler = getCurrencyChangeEventDelegate(type); if (handler != null) { handler -= callback; updateCurrencyChangeHandler(type, handler); } }
// Overloaded version if you want to override the currency amount: bool tryCallCurrencyChangeEvent(CurrencyType type, int amount) { m.MonoActionInt currencyChangeCallback = getCurrencyChangeEventDelegate(type); if (currencyChangeCallback != null) { currencyChangeCallback(amount); return(true); } else { return(false); } }
void updateCurrencyChangeHandler(CurrencyType type, m.MonoActionInt handler) { currencyChangeCallbacks[type] = handler; }
public void SubscribeToCurrencyChange(CurrencyType type, m.MonoActionInt callback) { m.MonoActionInt handler = getCurrencyChangeEventDelegate(type); handler += callback; updateCurrencyChangeHandler(type, handler); }