public void AddBalance(double amount, AccountManagerCurrencyEnum currency = AccountManagerCurrencyEnum.DEFAULT) { int currencyIndex = (int)currency; currencyTypes[currencyIndex].SetNewTargetForAccountBalance(amount); if (!currencyTypes[currencyIndex].IsAnimationRunning()) { StartCoroutine(currencyTypes[currencyIndex].AnimationForChangingAccountBalance( accountManagerSettings.listOfCurrencyInfos[currencyIndex].currencyAnimationDuration, accountManagerSettings.listOfCurrencyInfos[currencyIndex].animationCurve)); } }
public bool DeductBalance(double amount, AccountManagerCurrencyEnum currency = AccountManagerCurrencyEnum.DEFAULT) { int currencyIndex = (int)currency; double currentBalance = currencyTypes[currencyIndex].GetCurrentBalance(); if ((currentBalance - amount) >= 0) { AddBalance(-amount, currency); return(true); } Debug.LogError("Insufficient Balance!!"); return(false); }
public override void OnInspectorGUI() { CoreEditorModule.ShowScriptReference(serializedObject); serializedObject.Update(); EditorGUILayout.PropertyField(_sp_instanceBehaviour); EditorGUILayout.PropertyField(_sp_accountManagerSettings); if (_reference.accountManagerSettings != null) { CoreEditorModule.DrawSettingsEditor(_reference.accountManagerSettings, null, ref _reference.showAccountManagerSettings, ref _editorForAccountManagerSettings); if (EditorApplication.isPlaying) { CoreEditorModule.DrawHorizontalLine(); int numberOfCurrency = _reference.accountManagerSettings.GetNumberOfAvailableCurrency(); for (int i = 0; i < numberOfCurrency; i++) { AccountManagerCurrencyEnum currency = (AccountManagerCurrencyEnum)i; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(_reference.GetNameOfCurrency(currency) + " : " + _reference.GetCurrentBalance(currency)); if (GUILayout.Button("+1000", GUILayout.Width(100))) { _reference.AddBalance(1000, currency); } if (GUILayout.Button("-1000", GUILayout.Width(100))) { _reference.DeductBalance(1000, currency); } } EditorGUILayout.EndHorizontal(); } } } serializedObject.ApplyModifiedProperties(); }
public double GetCurrentBalance(AccountManagerCurrencyEnum currency = AccountManagerCurrencyEnum.DEFAULT) { return(currencyTypes[(int)currency].GetCurrentBalance()); }
public string GetNameOfCurrency(AccountManagerCurrencyEnum currency = AccountManagerCurrencyEnum.DEFAULT) { return(accountManagerSettings.listOfCurrencyInfos[(int)currency].currencyName); }
/// <summary> /// Invoke : Both when the currency updated in every frame and when the currency update get finished /// </summary> /// <param name="OnBalanceChanging"></param> /// <param name="OnBalanceChangeEnd"></param> /// <param name="currency"></param> public void OnBalanceChangeEvent(Action <double, CoreEnums.ValueChangedState> OnBalanceChanging, Action <double, CoreEnums.ValueChangedState> OnBalanceChangeEnd, AccountManagerCurrencyEnum currency = AccountManagerCurrencyEnum.DEFAULT) { int currencyIndex = (int)currency; currencyTypes[currencyIndex].OnBalanceChangingEvent += OnBalanceChanging; currencyTypes[currencyIndex].InvokeOnBalanceChangingEvent(currencyTypes[currencyIndex].GetCurrentBalance(), CoreEnums.ValueChangedState.VALUE_UNCHANGED); currencyTypes[currencyIndex].OnBalanceChangingEndEvent += OnBalanceChangeEnd; currencyTypes[currencyIndex].InvokeOnBalanceChangeEndEvent(currencyTypes[currencyIndex].GetCurrentBalance(), CoreEnums.ValueChangedState.VALUE_UNCHANGED); }