/// <summary> /// 处理塔罗牌升级或激活 /// </summary> /// <param name="client"></param> /// <param name="goodID"></param> /// <param name="partCount"></param> /// <returns></returns> public ETarotResult ProcessTarotUpCmd(GameClient client, int goodID) { //判断功能是否开启 if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.TarotCard)) { return(ETarotResult.NotOpen); } TarotSystemData tarotData = client.ClientData.TarotData; //获取要升级的塔罗牌数据 TarotCardData currentTarot = tarotData.TarotCardDatas.Find(x => x.GoodId == goodID); if (currentTarot == null) { //激活 currentTarot = new TarotCardData(); currentTarot.GoodId = goodID; tarotData.TarotCardDatas.Add(currentTarot); } //判断是否可以升级 if (currentTarot.Level >= TarotMaxLevelDict[goodID]) { return(ETarotResult.MaxLevel); } //获取下级塔罗牌对应配置模板 TarotTemplate nextTemp = TarotTemplates.Find(x => x.GoodsID == goodID && x.Level == currentTarot.Level + 1); if (nextTemp == null) { return(ETarotResult.Error); } //判断背包碎片是否足够 var hasPartCount = Global.GetTotalGoodsCountByID(client, nextTemp.NeedGoodID); if (hasPartCount < nextTemp.NeedPartCount) { return(ETarotResult.NeedPart); } //使用物品 优先使用绑定物品 bool usedBinding = false; bool usedTimeLimited = false; if (Global.UseGoodsBindOrNot(client, nextTemp.NeedGoodID, nextTemp.NeedPartCount, true, out usedBinding, out usedTimeLimited) < 1) { return(ETarotResult.NeedPart); } //处理升级 currentTarot.Level += 1; //更新玩家数据 UpdataPalyerTarotAttr(client); //向DB服更新数据 UpdateTarotData2DB(client, currentTarot, null); return(ETarotResult.Success); }
public void Initialize() { string fileName = Global.GameResPath("Config/Tarot.xml"); XElement xml = XElement.Load(fileName); if (null == xml) { throw new Exception(string.Format("加载系统xml配置文件:{0}, 失败。没有找到相关XML配置文件!", fileName)); } IEnumerable <XElement> xmlItems = xml.Elements(); foreach (XElement xmlItem in xmlItems) { var data = new TarotTemplate(); data.Level = Convert.ToInt32(Global.GetSafeAttributeStr(xmlItem, "Level")); //策划改了配置结构 服务器不需要读0配置 if (data.Level == 0) { continue; } data.ID = Convert.ToInt32(Global.GetSafeAttributeStr(xmlItem, "ID")); data.Name = Global.GetSafeAttributeStr(xmlItem, "Name"); data.GoodsID = Convert.ToInt32(Global.GetSafeAttributeStr(xmlItem, "GoodsID")); var needGoodsInfo = Global.GetSafeAttributeStr(xmlItem, "NeedGoods").Split(','); data.NeedGoodID = Convert.ToInt32(needGoodsInfo[0]); data.NeedPartCount = Convert.ToInt32(needGoodsInfo[1]); if (TarotMaxLevelDict.ContainsKey(data.GoodsID) && TarotMaxLevelDict[data.GoodsID] < data.Level) { TarotMaxLevelDict[data.GoodsID] = data.Level; } else { TarotMaxLevelDict.Add(data.GoodsID, data.Level); } TarotTemplates.Add(data); } TarotCardIds = TarotMaxLevelDict.Keys.ToList(); var kingCost = GameManager.systemParamsList.GetParamValueByName("TarotKingCost").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); KingItemId = Convert.ToInt32(kingCost[0]); UseKingItemCount = Convert.ToInt32(kingCost[1]); KingBuffTime = Convert.ToInt32(kingCost[2]) * 60; var kingValueInfo = GameManager.systemParamsList.GetParamValueByName("TarotKingNum").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var info in kingValueInfo) { KingBuffValueList.Add(Convert.ToInt32(info)); } TCPCmdDispatcher.getInstance().registerProcessorEx((int)TCPGameServerCmds.CMD_SPR_TAROT_UPORINIT, 1, 1, getInstance()); TCPCmdDispatcher.getInstance().registerProcessorEx((int)TCPGameServerCmds.CMD_SPR_SET_TAROTPOS, 2, 2, getInstance()); TCPCmdDispatcher.getInstance().registerProcessorEx((int)TCPGameServerCmds.CMD_SPR_USE_TAROTKINGPRIVILEGE, 1, 1, getInstance()); TCPCmdDispatcher.getInstance().registerProcessorEx((int)TCPGameServerCmds.CMD_SPR_TAROT_DATA, 1, 1, getInstance()); }