using System.Collections.Generic; using cfg.GfgCfg; using ET; namespace GFGGame { public class LimitCfgArray : SingletonBaseET { /// /// 根据已购次数和本次购买次数计算所需货币id和货币数量 /// /// 限购id /// 已购买次数 /// 请求的购买次数 /// out 消耗的货币id /// out 消耗的货币数量 public void GetMoneyIdAndNum(int chapterId, int hadBuyTimes, int buyTimesThis, out int moneyId, out int moneyNum) { var limitCfg = CommonDataManager.Tables.TblLimitCfg.GetOrDefault(chapterId); moneyId = limitCfg.MoneyId; moneyNum = 0; //每个次数单独计算消耗个数 for (var theBuyTimes = hadBuyTimes + 1; theBuyTimes <= hadBuyTimes + buyTimesThis; theBuyTimes++) { //每次从最高位检测 moneyNum += GetMoneyNum(limitCfg, theBuyTimes); } } //根据第几次购买获取消耗货币个数 public int GetMoneyNum(LimitCfg limitCfg, int theBuyTimes) { //每次从最高位检测 for (var i = limitCfg.MoneyBuyTimes.Count - 1; i >= 0; i--) { if (theBuyTimes >= limitCfg.MoneyBuyTimes[i]) { return limitCfg.MoneyNum[i]; } } return 0; } } }