// 加载图鉴项 private bool loadTuJianItem() { try { XElement xmlFile = GeneralCachingXmlMgr.GetXElement(Global.IsolateResPath(TuJianItem_fileName)); if (null == xmlFile) { LogManager.WriteLog(LogTypes.Error, string.Format("{0}不存在!", TuJianItem_fileName)); return(false); } IEnumerable <XElement> TuJianXEle = xmlFile.Elements(); foreach (var xmlItem in TuJianXEle) { if (null != xmlItem) { TuJianItem item = new TuJianItem(); item.TypeID = (int)Global.GetSafeAttributeDouble(xmlItem, "Type"); item.ItemID = (int)Global.GetSafeAttributeDouble(xmlItem, "ID"); item.Name = Global.GetSafeAttributeStr(xmlItem, "Name"); string strCostGoods = Global.GetSafeAttributeStr(xmlItem, "NeedGoods"); if (!string.IsNullOrEmpty(strCostGoods)) { string[] sArry = strCostGoods.Split(','); item.CostGoodsID = Global.SafeConvertToInt32(sArry[0]); item.CostGoodsCnt = Global.SafeConvertToInt32(sArry[1]); } string strAttrs = Global.GetSafeAttributeStr(xmlItem, "ShuXing"); item.AttrValue = analyseToAttrValues(strAttrs); TuJianItems.Add(item.ItemID, item); if (!TuJianTypes.ContainsKey(item.TypeID)) { LogManager.WriteLog(LogTypes.Error, string.Format("{0}配置了不存在的图鉴类型Type={1}", TuJianItem_fileName, item.TypeID)); return(false); } else { TuJianTypes[item.TypeID].ItemList.Add(item.ItemID); } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, string.Format("{0}读取出错!", TuJianItem_fileName), ex); return(false); } return(true); }
public bool GM_OneKeyActiveTuJianType(GameClient client, int typeId, out string failedMsg) { failedMsg = string.Empty; if (client == null) { failedMsg = "unknown"; return(false); } TuJianType type = null; if (!TuJianTypes.TryGetValue(typeId, out type)) { failedMsg = "图鉴类型找不到: " + typeId.ToString(); return(false); } // 等级不满足 if (client.ClientData.ChangeLifeCount < type.OpenChangeLife || (client.ClientData.ChangeLifeCount == type.OpenChangeLife && client.ClientData.Level < type.OpenLevel)) { failedMsg = "该项图鉴未开启,类型=" + typeId.ToString() + " ,需求转生:" + type.OpenChangeLife + " , 等级:" + type.OpenLevel; return(false); } bool bRealRefer = false; foreach (var itemId in type.ItemList) { TuJianItem item = null; if (!TuJianItems.TryGetValue(itemId, out item)) { continue; } // 该子项已激活 if (client.ClientData.PictureJudgeReferInfo.ContainsKey(itemId) && client.ClientData.PictureJudgeReferInfo[itemId] >= item.CostGoodsCnt) { continue; } string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, itemId, item.CostGoodsCnt); string[] dbRsp = Global.ExecuteDBCmd((int)TCPGameServerCmds.CMD_DB_REFERPICTUREJUDGE, strDbCmd, client.ServerId); if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0) { failedMsg = "数据库异常"; return(false); } bRealRefer = true; if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemId)) { client.ClientData.PictureJudgeReferInfo.Add(itemId, item.CostGoodsCnt); } else { client.ClientData.PictureJudgeReferInfo[itemId] = item.CostGoodsCnt; } } // 只有在任何一项提交成功时,才重新计算属性加成 if (bRealRefer) { client.sendCmd(DataHelper.ObjectToTCPOutPacket <Dictionary <int, int> >(client.ClientData.PictureJudgeReferInfo, Global._TCPManager.TcpOutPacketPool, (int)TCPGameServerCmds.CMD_SPR_REFERPICTUREJUDGE)); UpdateTuJianProps(client); // 激活的图鉴项变化了,检查守护雕像的激活情况 GuardStatueManager.Instance().OnActiveTuJian(client); // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.CompleteTuJian)); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } return(true); }
// 玩家激活图鉴 public void HandleActiveTuJian(GameClient client, string[] itemArr) { if (itemArr == null || itemArr.Length == 0 || client == null) { return; } bool anySuccess = false; foreach (string strItemID in itemArr) { // 客户端请求激活的图鉴Item int itemID = Convert.ToInt32(strItemID); TuJianItem item = null; TuJianType type = null; if (!TuJianItems.TryGetValue(itemID, out item) || !TuJianTypes.TryGetValue(item.TypeID, out type)) { continue; } // 等级不满足 if (client.ClientData.ChangeLifeCount < type.OpenChangeLife || (client.ClientData.ChangeLifeCount == type.OpenChangeLife && client.ClientData.Level < type.OpenLevel)) { continue; } int hadReferCnt = 0; if (client.ClientData.PictureJudgeReferInfo.ContainsKey(itemID)) { hadReferCnt = client.ClientData.PictureJudgeReferInfo[itemID]; } // 已激活 if (hadReferCnt >= item.CostGoodsCnt) { continue; } int needReferCnt = item.CostGoodsCnt - hadReferCnt; int hasGoodsCnt = Global.GetTotalGoodsCountByID(client, item.CostGoodsID); // 材料不足 if (hasGoodsCnt <= 0) { continue; } // 允许提交一部分材料 int thisTimeReferCnt = Math.Min(needReferCnt, hasGoodsCnt); bool usedBinding_just_placeholder = false; bool usedTimeLimited_just_placeholder = false; // 扣除物品失败 if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.CostGoodsID, thisTimeReferCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder)) { continue; } string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, itemID, hadReferCnt + thisTimeReferCnt); string[] dbRsp = Global.ExecuteDBCmd((int)TCPGameServerCmds.CMD_DB_REFERPICTUREJUDGE, strDbCmd, client.ServerId); if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0) { LogManager.WriteLog(LogTypes.Error, string.Format("角色RoleID={0},RoleName={1} 激活图鉴Item={2}时,与db通信失败,物品已扣除GoodsID={3},Cnt={4}", client.ClientData.RoleID, client.ClientData.RoleName, itemID, item.CostGoodsID, thisTimeReferCnt)); continue; } anySuccess = true; if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemID)) { client.ClientData.PictureJudgeReferInfo.Add(itemID, hadReferCnt + thisTimeReferCnt); } else { client.ClientData.PictureJudgeReferInfo[itemID] = hadReferCnt + thisTimeReferCnt; } } // 只有在任何一项提交成功时,才重新计算属性加成 if (anySuccess) { UpdateTuJianProps(client); // 激活的图鉴项变化了,检查守护雕像的激活情况 GuardStatueManager.Instance().OnActiveTuJian(client); // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.CompleteTuJian)); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } }
// 计算图鉴系统属性加成 public void UpdateTuJianProps(GameClient client) { if (client == null) { return; } if (client.ClientData.PictureJudgeReferInfo == null || client.ClientData.PictureJudgeReferInfo.Count == 0) { return; } // 统计每个图鉴Type激活了多少个Item Dictionary <int, int> activeItemByType = new Dictionary <int, int>(); // 计算图鉴总属性 _AttrValue totalAttrValue = new _AttrValue(); // 计算激活的图鉴Item加成 foreach (var kvp in client.ClientData.PictureJudgeReferInfo) { int itemID = kvp.Key; int itemReferCnt = kvp.Value; TuJianItem item = null; if (!TuJianItems.TryGetValue(itemID, out item)) { continue; } // 本item已激活 if (itemReferCnt >= item.CostGoodsCnt) { if (!activeItemByType.ContainsKey(item.TypeID)) { activeItemByType.Add(item.TypeID, 0); } activeItemByType[item.TypeID]++; totalAttrValue.Add(item.AttrValue); if (client.ClientData.ActivedTuJianItem != null && !client.ClientData.ActivedTuJianItem.Contains(itemID)) { client.ClientData.ActivedTuJianItem.Add(itemID); } } } // 计算图鉴Type加成(只有所有子item全部激活的图鉴type) foreach (var kvp in activeItemByType) { TuJianType type = null; if (!TuJianTypes.TryGetValue(kvp.Key, out type)) { continue; } // 本图鉴type全部激活 if (kvp.Value >= type.ItemCnt) { totalAttrValue.Add(type.AttrValue); if (client.ClientData.ActivedTuJianType != null && !client.ClientData.ActivedTuJianType.Contains(kvp.Key)) { client.ClientData.ActivedTuJianType.Add(kvp.Key); } } } client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MinAttack, totalAttrValue.MinAttack); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MaxAttack, totalAttrValue.MaxAttack); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MinMAttack, totalAttrValue.MinMAttack); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MaxMAttack, totalAttrValue.MaxMAttack); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MinDefense, totalAttrValue.MinDefense); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MaxDefense, totalAttrValue.MaxDefense); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MinMDefense, totalAttrValue.MinMDefense); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MaxMDefense, totalAttrValue.MaxMDefense); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.HitV, totalAttrValue.HitV); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MaxLifeV, totalAttrValue.MaxLifeV); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.Dodge, totalAttrValue.Dodge); }
public bool GM_OneKeyActiveTuJianType(GameClient client, int typeId, out string failedMsg) { failedMsg = string.Empty; bool result; if (client == null) { failedMsg = "unknown"; result = false; } else { TuJianType type = null; if (!this.TuJianTypes.TryGetValue(typeId, out type)) { failedMsg = "图鉴类型找不到: " + typeId.ToString(); result = false; } else if (client.ClientData.ChangeLifeCount < type.OpenChangeLife || (client.ClientData.ChangeLifeCount == type.OpenChangeLife && client.ClientData.Level < type.OpenLevel)) { failedMsg = string.Concat(new object[] { "该项图鉴未开启,类型=", typeId.ToString(), " ,需求转生:", type.OpenChangeLife, " , 等级:", type.OpenLevel }); result = false; } else { bool bRealRefer = false; foreach (int itemId in type.ItemList) { TuJianItem item = null; if (this.TuJianItems.TryGetValue(itemId, out item)) { if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemId) || client.ClientData.PictureJudgeReferInfo[itemId] < item.CostGoodsCnt) { string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, itemId, item.CostGoodsCnt); string[] dbRsp = Global.ExecuteDBCmd(10155, strDbCmd, client.ServerId); if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0) { failedMsg = "数据库异常"; return(false); } bRealRefer = true; if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemId)) { client.ClientData.PictureJudgeReferInfo.Add(itemId, item.CostGoodsCnt); } else { client.ClientData.PictureJudgeReferInfo[itemId] = item.CostGoodsCnt; } } } } if (bRealRefer) { client.sendCmd(DataHelper.ObjectToTCPOutPacket <Dictionary <int, int> >(client.ClientData.PictureJudgeReferInfo, Global._TCPManager.TcpOutPacketPool, 612), true); this.UpdateTuJianProps(client); SingletonTemplate <GuardStatueManager> .Instance().OnActiveTuJian(client); GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.CompleteTuJian)); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7); } result = true; } } return(result); }
public void HandleActiveTuJian(GameClient client, string[] itemArr) { if (itemArr != null && itemArr.Length != 0 && client != null) { bool anySuccess = false; foreach (string strItemID in itemArr) { int itemID = Convert.ToInt32(strItemID); TuJianItem item = null; TuJianType type = null; if (this.TuJianItems.TryGetValue(itemID, out item) && this.TuJianTypes.TryGetValue(item.TypeID, out type)) { if (client.ClientData.ChangeLifeCount >= type.OpenChangeLife && (client.ClientData.ChangeLifeCount != type.OpenChangeLife || client.ClientData.Level >= type.OpenLevel)) { int hadReferCnt = 0; if (client.ClientData.PictureJudgeReferInfo.ContainsKey(itemID)) { hadReferCnt = client.ClientData.PictureJudgeReferInfo[itemID]; } if (hadReferCnt < item.CostGoodsCnt) { int needReferCnt = item.CostGoodsCnt - hadReferCnt; int hasGoodsCnt = Global.GetTotalGoodsCountByID(client, item.CostGoodsID); if (hasGoodsCnt > 0) { int thisTimeReferCnt = Math.Min(needReferCnt, hasGoodsCnt); bool usedBinding_just_placeholder = false; bool usedTimeLimited_just_placeholder = false; if (GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.CostGoodsID, thisTimeReferCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder, false)) { string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, itemID, hadReferCnt + thisTimeReferCnt); string[] dbRsp = Global.ExecuteDBCmd(10155, strDbCmd, client.ServerId); if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0) { LogManager.WriteLog(LogTypes.Error, string.Format("角色RoleID={0},RoleName={1} 激活图鉴Item={2}时,与db通信失败,物品已扣除GoodsID={3},Cnt={4}", new object[] { client.ClientData.RoleID, client.ClientData.RoleName, itemID, item.CostGoodsID, thisTimeReferCnt }), null, true); } else { anySuccess = true; if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemID)) { client.ClientData.PictureJudgeReferInfo.Add(itemID, hadReferCnt + thisTimeReferCnt); } else { client.ClientData.PictureJudgeReferInfo[itemID] = hadReferCnt + thisTimeReferCnt; } ProcessTask.ProcessAddTaskVal(client, TaskTypes.JiHuoTuJian, -1, 1, new object[0]); } } } } } } } if (anySuccess) { this.UpdateTuJianProps(client); SingletonTemplate <GuardStatueManager> .Instance().OnActiveTuJian(client); GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.CompleteTuJian)); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7); } } }
public void UpdateTuJianProps(GameClient client) { if (client != null) { if (client.ClientData.PictureJudgeReferInfo != null && client.ClientData.PictureJudgeReferInfo.Count != 0) { Dictionary <int, int> activeItemByType = new Dictionary <int, int>(); _AttrValue totalAttrValue = new _AttrValue(); foreach (KeyValuePair <int, int> kvp in client.ClientData.PictureJudgeReferInfo) { int itemID = kvp.Key; int itemReferCnt = kvp.Value; TuJianItem item = null; if (this.TuJianItems.TryGetValue(itemID, out item)) { if (itemReferCnt >= item.CostGoodsCnt) { if (!activeItemByType.ContainsKey(item.TypeID)) { activeItemByType.Add(item.TypeID, 0); } Dictionary <int, int> dictionary; int typeID; (dictionary = activeItemByType)[typeID = item.TypeID] = dictionary[typeID] + 1; totalAttrValue.Add(item.AttrValue); if (client.ClientData.ActivedTuJianItem != null && !client.ClientData.ActivedTuJianItem.Contains(itemID)) { client.ClientData.ActivedTuJianItem.Add(itemID); } } } } foreach (KeyValuePair <int, int> kvp in activeItemByType) { TuJianType type = null; if (this.TuJianTypes.TryGetValue(kvp.Key, out type)) { if (kvp.Value >= type.ItemCnt) { totalAttrValue.Add(type.AttrValue); if (client.ClientData.ActivedTuJianType != null && !client.ClientData.ActivedTuJianType.Contains(kvp.Key)) { client.ClientData.ActivedTuJianType.Add(kvp.Key); } } } } client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 7, totalAttrValue.MinAttack }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 8, totalAttrValue.MaxAttack }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 9, totalAttrValue.MinMAttack }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 10, totalAttrValue.MaxMAttack }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 3, totalAttrValue.MinDefense }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 4, totalAttrValue.MaxDefense }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 5, totalAttrValue.MinMDefense }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 6, totalAttrValue.MaxMDefense }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 18, totalAttrValue.HitV }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 13, totalAttrValue.MaxLifeV }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 19, totalAttrValue.Dodge }); } } }