| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using ET;
- using System.Collections.Generic;
- using cfg.GfgCfg;
- namespace GFGGame
- {
- public class ItemExchangeCfgArray : SingletonBaseET<ItemExchangeCfgArray>
- {
- //根据已兑换次数和本次兑换次数计算所需消耗id和消耗数量
- public void GetMoneyIdAndNum(int itemId, int exchangedTimes, int exchangeTimesThis, out int costId,
- out int costNum, out int buyNum)
- {
- ItemExchangeCfg itemExchangeCfg = CommonDataManager.Tables.TblItemExchangeCfg.GetOrDefault(itemId);
- costId = itemExchangeCfg.CostId;
- costNum = 0;
- buyNum = 0;
- for (var i = exchangedTimes + 1; i <= exchangedTimes + exchangeTimesThis; i++)
- {
- GetCostAndBuyNum(itemExchangeCfg, i, out int _costNum, out int _buyNum);
- costNum += _costNum;
- buyNum += _buyNum;
- }
- }
- //根据第几次购买获取消耗货币个数
- public void GetCostAndBuyNum(ItemExchangeCfg itemExchangeCfg, int theExchangeTimes, out int costNum,
- out int buyNum)
- {
- costNum = 0;
- buyNum = 0;
- //每次从最高位检测
- if (itemExchangeCfg.Times.Count > 0)
- {
- for (var i = itemExchangeCfg.Times.Count - 1; i >= 0; i--)
- {
- var time = itemExchangeCfg.Times[i];
- if (theExchangeTimes >= time)
- {
- costNum = itemExchangeCfg.CostNum[i];
- buyNum = itemExchangeCfg.Num;
- break;
- }
- }
- }
- else
- {
- costNum = itemExchangeCfg.CostNum[0];
- buyNum = itemExchangeCfg.Num;
- }
- }
- }
- }
|