/// <summary> /// 消耗货币 /// </summary> public void costCurrency(int type, long value, int way) { if (value <= 0) { return; } long[] currencies; long v = (currencies = _d.currencies)[type]; if ((v -= value) < 0) { value = v; v = 0; } currencies[type] = v; toLogCostCurrency(type, value, way); me.dispatch(GameEventType.RefreshCurrency, type); if (CommonSetting.isClientDriveLogic && CurrencyConfig.get(type).needAddRecord) { me.quest.taskEvent(TaskType.TotalCostCurrency, type, (int)(_d.totalAddCurrencies[type] - _d.currencies[type])); } onCostCurrency(type, value); }
/// <summary> /// 添加货币(只能加不能减)(客户端驱动模式下) /// </summary> public void addCurrency(int type, long value, int way, bool isAbs) { if (value <= 0) { return; } if (value <= 0) { return; } long now = _d.currencies[type]; if (!isAbs || !CurrencyConfig.get(type).canOverMaxByAbs) { long max; if ((max = _currenciesMax[type]) > 0) { //达到上限 if (now >= max) { return; } //本次可加值 if (now + value >= max) { value = max - now; } } } now = (_d.currencies[type] += value); toLogAddCurrency(type, value, way); me.dispatch(GameEventType.RefreshCurrency, type); //需要增加记录 if (CommonSetting.isClientDriveLogic && CurrencyConfig.get(type).needAddRecord) { int v2 = (int)(_d.totalAddCurrencies[type] += value); me.quest.taskEvent(TaskType.TotalAddCurrency, type, v2); } onAddCurrency(type, value); }