/// <summary> /// 限制类物品检测是否可以使用 /// </summary> /// <param name="client">GameClient</param> /// <param name="goodsID">物品ID</param> /// <param name="failedMsg">[out]不可使用的信息提示</param> /// <returns>可以使用返回True,同时failedMsg为NULL。否则返回False,failedMsg指示不可使用原因</returns> public bool CheckCanUse_ByToType(GameClient client, int goodsID, out string failedMsg) { failedMsg = ""; SystemXmlItem systemGoodsItem = null; if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsID, out systemGoodsItem)) { return(false); } string condIdx = systemGoodsItem.GetStringValue("ToType"); string condArg = systemGoodsItem.GetStringValue("ToTypeProperty"); // 未配置限制条件,认为可以使用 if (string.IsNullOrEmpty(condIdx) || condIdx == "-1") { return(true); } condIdx = condIdx.ToLower(); ICondJudger judger = null; if (!canUseDict.TryGetValue(condIdx, out judger)) { // 没有找到限制处理程序,默认可以使用 return(true); } return(judger.Judge(client, condArg, out failedMsg)); }
public bool CheckCanUse_ByToType(GameClient client, int goodsID, out string failedMsg) { failedMsg = ""; SystemXmlItem systemGoodsItem = null; bool result; if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsID, out systemGoodsItem)) { result = false; } else { string condIdx = systemGoodsItem.GetStringValue("ToType"); string condArg = systemGoodsItem.GetStringValue("ToTypeProperty"); if (string.IsNullOrEmpty(condIdx) || condIdx == "-1") { result = true; } else { condIdx = condIdx.ToLower(); ICondJudger judger = null; result = (!this.canUseDict.TryGetValue(condIdx, out judger) || judger.Judge(client, condArg, out failedMsg)); } } return(result); }
private static ExtensionPropItem ParseCachingItem(SystemXmlItem systemXmlItem) { return(new ExtensionPropItem { ID = systemXmlItem.GetIntValue("ID", -1), PrevTuoZhanShuXing = ExtensionPropsMgr.ParseDict(systemXmlItem.GetStringValue("PrevTuoZhanShuXing")), TargetType = systemXmlItem.GetIntValue("TargetTyp", -1), ActionType = systemXmlItem.GetIntValue("ActionType", -1), Probability = (int)(systemXmlItem.GetDoubleValue("Probability") * 100.0), NeedSkill = ExtensionPropsMgr.ParseDict(systemXmlItem.GetStringValue("NeedSkill")), Icon = systemXmlItem.GetIntValue("Icon", -1), TargetDecoration = systemXmlItem.GetIntValue("TargetDecoration", -1), DelayDecoration = systemXmlItem.GetIntValue("DelayDecoration", -1) }); }
private static BossAIItem ParseBossAICachingItem(SystemXmlItem systemXmlItem) { BossAIItem bossAIItem = new BossAIItem { ID = systemXmlItem.GetIntValue("ID", -1), AIID = systemXmlItem.GetIntValue("AIID", -1), TriggerNum = systemXmlItem.GetIntValue("TriggerNum", -1), TriggerCD = systemXmlItem.GetIntValue("TriggerCD", -1), TriggerType = systemXmlItem.GetIntValue("TriggerType", -1), Desc = systemXmlItem.GetStringValue("Description") }; bossAIItem.Condition = BossAICachingMgr.ParseCondition(bossAIItem.ID, bossAIItem.TriggerType, systemXmlItem.GetStringValue("Condition")); BossAIItem result; if (null == bossAIItem.Condition) { result = null; } else { result = bossAIItem; } return(result); }
/// <summary> /// 从xml项中解析缓存项 /// </summary> /// <param name="systemXmlItem"></param> private static ExtensionPropItem ParseCachingItem(SystemXmlItem systemXmlItem) { ExtensionPropItem extensionPropItem = new ExtensionPropItem() { ID = systemXmlItem.GetIntValue("ID"), PrevTuoZhanShuXing = ParseDict(systemXmlItem.GetStringValue("PrevTuoZhanShuXing")), TargetType = systemXmlItem.GetIntValue("TargetTyp"), ActionType = systemXmlItem.GetIntValue("ActionType"), Probability = (int)(systemXmlItem.GetDoubleValue("Probability") * 100), NeedSkill = ParseDict(systemXmlItem.GetStringValue("NeedSkill")), Icon = systemXmlItem.GetIntValue("Icon"), TargetDecoration = systemXmlItem.GetIntValue("TargetDecoration"), DelayDecoration = systemXmlItem.GetIntValue("DelayDecoration"), }; return(extensionPropItem); }
/// <summary> /// 从xml项中解析Boss AI缓存项 /// </summary> /// <param name="systemXmlItem"></param> private static BossAIItem ParseBossAICachingItem(SystemXmlItem systemXmlItem) { BossAIItem bossAIItem = new BossAIItem() { ID = systemXmlItem.GetIntValue("ID"), AIID = systemXmlItem.GetIntValue("AIID"), TriggerNum = systemXmlItem.GetIntValue("TriggerNum"), TriggerCD = systemXmlItem.GetIntValue("TriggerCD"), TriggerType = systemXmlItem.GetIntValue("TriggerType"), Desc = systemXmlItem.GetStringValue("Description"), }; bossAIItem.Condition = ParseCondition(bossAIItem.ID, bossAIItem.TriggerType, systemXmlItem.GetStringValue("Condition")); if (null == bossAIItem.Condition) { return(null); } return(bossAIItem); }
public bool processCmd(Logic.GameClient client, string[] cmdParams) { int nID = (int)TCPGameServerCmds.CMD_SPR_WINGUPGRADE; int nRoleID = Global.SafeConvertToInt32(cmdParams[0]); int nUpWingMode = Global.SafeConvertToInt32(cmdParams[1]); //0: 道具进阶, 1: 钻石进阶 string strCmd = ""; if (null == client.ClientData.MyWingData) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 已到最高级 if (client.ClientData.MyWingData.WingID >= MUWingsManager.MaxWingID) { strCmd = string.Format("{0}:{1}:{2}:{3}", -8, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 获取进阶信息表 SystemXmlItem upStarXmlItem = MUWingsManager.GetWingUPCacheItem(client.ClientData.MyWingData.WingID + 1); if (null == upStarXmlItem) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } if (0 == nUpWingMode) { // 获取进阶需要的道具的物品信息 string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods"); // 解析物品ID与数量 string[] itemParams = strReqItemID.Split(','); if (null == itemParams || itemParams.Length != 2) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } int originGoodsID = Convert.ToInt32(itemParams[0]); int originGoodsNum = Convert.ToInt32(itemParams[1]); if (originGoodsID <= 0 || originGoodsNum <= 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } GoodsReplaceResult replaceRet = GoodsReplaceManager.Instance().GetReplaceResult(client, originGoodsID); if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum) { // 物品数量不够 strCmd = string.Format("{0}:{1}:{2}:{3}", -4, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>(); // 1:替换后的绑定材料 // 2:替换后的非绑定材料 // 3:原始绑定材料 // 4:原始非绑定材料 realCostList.AddRange(replaceRet.BindList); realCostList.AddRange(replaceRet.UnBindList); realCostList.Add(replaceRet.OriginBindGoods); realCostList.Add(replaceRet.OriginUnBindGoods); int hasUseCnt = 0; int stillNeedCnt = originGoodsNum; foreach (var item in realCostList) { if (item.GoodsCnt <= 0) { continue; } int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt); if (realCostCnt <= 0) { break; } bool bUsedBinding = false; bool bUsedTimeLimited = false; bool bFailed = false; if (item.IsBind) { if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited)) { bFailed = true; } } else { if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited)) { bFailed = true; } } stillNeedCnt -= realCostCnt; if (bFailed) { strCmd = string.Format("{0}:{1}:{2}:{3}", -5, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } } } else { // 获取进阶需要的钻石数量 int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi"); if (nReqZuanShi <= 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 判断用户点卷额是否不足【钻石】 if (client.ClientData.UserMoney < nReqZuanShi) { //用户点卷额不足【钻石】 strCmd = string.Format("{0}:{1}:{2}:{3}", -6, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } //先DBServer请求扣费 //扣除用户点卷 if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀进阶")) { //扣除用户点卷失败 strCmd = string.Format("{0}:{1}:{2}:{3}", -7, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } } int nLuckOne = upStarXmlItem.GetIntValue("LuckyOne"); int nLuckyTwo = upStarXmlItem.GetIntValue("LuckyTwo"); int nLuckTwoRate = (int)(upStarXmlItem.GetDoubleValue("LuckyTwoRate") * 100.0); int nNextWingID = client.ClientData.MyWingData.WingID; int nNextJinJieFailedNum = client.ClientData.MyWingData.JinJieFailedNum; int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarExp = client.ClientData.MyWingData.StarExp; // LuckyOne+提升获得幸运点 < LuckyTwo;必定不会提升成功 if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < nLuckyTwo) { // 幸运点加1 nNextJinJieFailedNum++; } // LuckyOne+提升获得幸运点>= LuckyTwo,则根据配置得到LuckyTwoRate概率判定是否能够完成进阶操作 else if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < 110000) { // int nRandNum = Global.GetRandomNumber(0, 100); if (nRandNum < nLuckTwoRate) { // 进阶成功 nNextWingID++; // 幸运点清0 nNextJinJieFailedNum = 0; // 星级清0 nNextStarLevel = 0; // 星级经验清0 nNextStarExp = 0; } else { // 幸运点加1 nNextJinJieFailedNum++; } } // LuckyOne+提升获得幸运点>=110000时,进阶必定成功 else { // 进阶成功 nNextWingID++; // 幸运点清0 nNextJinJieFailedNum = 0; // 星级清0 nNextStarLevel = 0; // 星级经验清0 nNextStarExp = 0; } // 七日活动 // 翅膀升级和升阶次数,成功失败都算 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes)); // 将改变保存到数据库 int iRet = MUWingsManager.WingUpDBCommand(client, client.ClientData.MyWingData.DbID, nNextWingID, nNextJinJieFailedNum, nNextStarLevel, nNextStarExp, client.ClientData.MyWingData.ZhuLingNum, client.ClientData.MyWingData.ZhuHunNum); if (iRet < 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } else { strCmd = string.Format("{0}:{1}:{2}:{3}", 0, nRoleID, nNextWingID, nNextJinJieFailedNum); client.sendCmd(nID, strCmd); client.ClientData.MyWingData.JinJieFailedNum = nNextJinJieFailedNum; if (client.ClientData.MyWingData.WingID != nNextWingID) { // 先移除原来的属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, false); } bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu); // 更新翅膀的新等级,星数 client.ClientData.MyWingData.WingID = nNextWingID; client.ClientData.MyWingData.ForgeLevel = 0; client.ClientData.MyWingData.StarExp = 0; // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel)); bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu); if (!oldWingLingYuOpened && newWingLingYuOpened) { //翎羽功能开启了,初始化 LingYuManager.InitAsOpened(client); } // 按新等级增加属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, true); //升阶时候,翅膀的基础属性的改变会影响注魂加成 ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } //[bing] 刷新客户端活动叹号 if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing)) { client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived()); client._IconStateMgr.SendIconStateToClient(client); } } } return(true); }
/// <summary> /// 翅膀升星处理 /// </summary> public bool processCmd(Logic.GameClient client, string[] cmdParams) { int nID = (int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR; int nRoleID = Global.SafeConvertToInt32(cmdParams[0]); int nUpStarMode = Global.SafeConvertToInt32(cmdParams[1]); //0: 道具升星, 1: 钻石升星 string strCmd = ""; if (null == client.ClientData.MyWingData) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 获取升星信息表 SystemXmlItem upStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel + 1); if (null == upStarXmlItem) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } string strWingShengXing = GameManager.systemParamsList.GetParamValueByName("WingShengXing"); if ("" == strWingShengXing) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 解析升级暴率 string[] wingShengXing = strWingShengXing.Split(','); if (3 != wingShengXing.Length) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 暴率 int nPowRate = 0; // 增加的星经验 int nAddExp = 0; if (0 == nUpStarMode) { nPowRate = (int)(Convert.ToDouble(wingShengXing[0]) * 100.0); nAddExp = Convert.ToInt32(upStarXmlItem.GetIntValue("GoodsExp")); } else { nPowRate = (int)(Convert.ToDouble(wingShengXing[1]) * 100.0); nAddExp = Convert.ToInt32(upStarXmlItem.GetIntValue("ZuanShiExp")); } // 暴升,乘以经验倍数 int nRandNum = Global.GetRandomNumber(0, 100); if (nRandNum < nPowRate) { nAddExp *= Convert.ToInt32(wingShengXing[2]); } int nUpStarReqExp = upStarXmlItem.GetIntValue("StarExp"); int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarExp = 0; if (client.ClientData.MyWingData.StarExp + nAddExp >= nUpStarReqExp) { if (nNextStarLevel < MUWingsManager.MaxWingEnchanceLevel) { // 改变星级,剩余的经验改到下级 nNextStarLevel += 1; nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp - nUpStarReqExp; // 连续升星 while (true) { if (nNextStarLevel >= MUWingsManager.MaxWingEnchanceLevel) { break; } SystemXmlItem nextStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, nNextStarLevel + 1); if (null == upStarXmlItem) { break; } int nNextUpStarReqExp = nextStarXmlItem.GetIntValue("StarExp"); if (nNextStarExp >= nNextUpStarReqExp) { nNextStarLevel += 1; nNextStarExp = nNextStarExp - nNextUpStarReqExp; } else { break; } } } else { // 已经达到最高星 nNextStarExp = nUpStarReqExp; } } else { nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp; } if (0 == nUpStarMode) { //获取强化需要的道具的物品ID string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods"); // 解析物品ID与数量 string[] itemParams = strReqItemID.Split(','); if (null == itemParams || itemParams.Length != 2) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } //获取强化需要的道具的物品ID int nEnchanceNeedGoodsID = Convert.ToInt32(itemParams[0]); //获取强化需要的道具的物品数量 int nEnchanceNeedGoodsNum = Convert.ToInt32(itemParams[1]); if (nEnchanceNeedGoodsID <= 0 || nEnchanceNeedGoodsNum <= 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 判断数量是否够 if (Global.GetTotalGoodsCountByID(client, nEnchanceNeedGoodsID) < nEnchanceNeedGoodsNum) { // 物品数量不够 strCmd = string.Format("{0}:{1}:{2}:{3}", -4, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } //自动扣除物品 if (nEnchanceNeedGoodsNum > 0) { bool bUsedBinding = false; bool bUsedTimeLimited = false; //扣除物品 if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nEnchanceNeedGoodsID, nEnchanceNeedGoodsNum, false, out bUsedBinding, out bUsedTimeLimited)) { strCmd = string.Format("{0}:{1}:{2}:{3}", -5, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } } } else { // 获取强化需要的钻石数量 int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi"); if (nReqZuanShi <= 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } //判断用户点卷额是否不足【钻石】 if (client.ClientData.UserMoney < nReqZuanShi) { //用户点卷额不足【钻石】 strCmd = string.Format("{0}:{1}:{2}:{3}", -6, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } //先DBServer请求扣费 //扣除用户点卷 if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀升星")) { //扣除用户点卷失败 strCmd = string.Format("{0}:{1}:{2}:{3}", -7, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } } // 将改变保存到数据库 int iRet = MUWingsManager.WingUpStarDBCommand(client, client.ClientData.MyWingData.DbID, nNextStarLevel, nNextStarExp); if (iRet < 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } else { strCmd = string.Format("{0}:{1}:{2}:{3}", 0, nRoleID, nNextStarLevel, nNextStarExp); client.sendCmd(nID, strCmd); client.ClientData.MyWingData.StarExp = nNextStarExp; if (client.ClientData.MyWingData.ForgeLevel != nNextStarLevel) { // 先移除原来的属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, false); } client.ClientData.MyWingData.ForgeLevel = nNextStarLevel; // 按新等级增加属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, true); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } } } return(true); }
public bool processCmd(GameClient client, string[] cmdParams) { int roleID = Global.SafeConvertToInt32(cmdParams[0]); int bhid = Global.SafeConvertToInt32(cmdParams[1]); int buildType = Global.SafeConvertToInt32(cmdParams[2]); int toLevel = Math.Max(2, Global.SafeConvertToInt32(cmdParams[3])); int nID = 601; bool result; if (client.ClientData.Faction != bhid) { string strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", new object[] { -1, roleID, bhid, buildType, 0 }); client.sendCmd(nID, strcmd, false); result = true; } else if (toLevel > Global.MaxBangHuiFlagLevel) { string strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", new object[] { -2, roleID, bhid, buildType, 0 }); client.sendCmd(nID, strcmd, false); result = true; } else { SystemXmlItem systemZhanMengBuildItem = Global.GetZhanMengBuildItem(buildType, toLevel); if (null == systemZhanMengBuildItem) { string strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", new object[] { -3, roleID, bhid, buildType, 0 }); client.sendCmd(nID, strcmd, false); result = true; } else { BangHuiDetailData bangHuiDetailData = Global.GetBangHuiDetailData(roleID, bhid, 0); int oldBanHuiMoney = bangHuiDetailData.TotalMoney; int levelupCost = systemZhanMengBuildItem.GetIntValue("LevelupCost", -1); string strReqGoods = systemZhanMengBuildItem.GetStringValue("NeedGoods"); string dbcmd = string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}", new object[] { roleID, bhid, buildType, levelupCost, toLevel, Global.GetZhanMengInitCoin(), strReqGoods }); string[] fields = Global.ExecuteDBCmd(nID, dbcmd, client.ServerId); if (fields == null || fields.Length != 1) { LogManager.WriteLog(LogTypes.Error, string.Format("升级帮旗等级时失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(client.ClientSocket, false), roleID), null, true); result = false; } else { int retCode = Global.SafeConvertToInt32(fields[0]); string strcmd; if (retCode >= 0) { Global.BroadcastZhanMengBuildUpLevelHint(client, buildType, toLevel); strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", new object[] { toLevel, roleID, bhid, buildType, levelupCost }); JunQiManager.NotifySyncBangHuiJunQiItemsDict(client); GameManager.ClientMgr.NotifyBangHuiUpLevel(bhid, client.ServerId, toLevel, client.ClientSocket.IsKuaFuLogin); BangHuiDetailData bangHuiDetailDataNew = Global.GetBangHuiDetailData(roleID, bhid, 0); int newBanHuiMoney = bangHuiDetailDataNew.TotalMoney; string strCostList = EventLogManager.NewResPropString(ResLogType.BangHuiMoney, new object[] { -levelupCost, oldBanHuiMoney, newBanHuiMoney }); EventLogManager.AddBangHuiBuildUpEvent(client, bhid, buildType, toLevel, strCostList); } else { strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", new object[] { retCode, roleID, bhid, buildType, 0 }); } client.sendCmd(nID, strcmd, false); result = true; } } } return(result); }
/// <summary> /// 检测目标是否在攻击范围内 /// </summary> /// <param name="direction"></param> /// <returns></returns> private bool testAttackDistance(out int direction) { direction = 0; SystemXmlItem systemMagic = null; if (!GameManager.SystemMagicsMgr.SystemXmlItemDict.TryGetValue(skillId, out systemMagic)) { return(false); } // 扫描类型 [11/27/2013 LiaoWei] List <MagicActionItem> magicScanTypeItemList = null; if (!GameManager.SystemMagicScanTypeMgr.MagicActionsDict.TryGetValue(skillId, out magicScanTypeItemList) || null == magicScanTypeItemList) { /*return false;*/ } List <MagicActionItem> magicActionItemList = null; if (!GameManager.SystemMagicActionMgr.MagicActionsDict.TryGetValue(skillId, out magicActionItemList) || null == magicActionItemList) { return(false); } MagicActionItem magicScanTypeItem = null; if (null != magicScanTypeItemList && magicScanTypeItemList.Count > 0) { magicScanTypeItem = magicScanTypeItemList[0]; } //技能施法距离 int attackDistance = systemMagic.GetIntValue("AttackDistance"); //如果是锁定目标单体攻击只校验技能施法距离 if (systemMagic.GetIntValue("MagicType") == (int)EMagicType.EMT_Single || systemMagic.GetIntValue("MagicType") == (int)EMagicType.EMT_AutoTrigger) // 单体或自动触发 { int targetType = systemMagic.GetIntValue("TargetType"); // 技能目标类型 if ((int)EMagicTargetType.EMTT_Self == targetType) //自身 { //判断距离 if (Global.GetTwoPointDistance(owner.CurrentPos, target.CurrentPos) > attackDistance) { return(false);; } else { return(true); } } else if ((int)EMagicTargetType.EMTT_SelfAndTeam == targetType) { return(false); } } else //群攻 { Point targetPos; int attackDirection = 0; //首先根据配置文件算出目标中心点 if ((int)EAttackTargetPos.EATP_Self == systemMagic.GetIntValue("TargetPos")) //自身 { targetPos = owner.CurrentPos; } else if ((int)EAttackTargetPos.EATP_TargetLock == systemMagic.GetIntValue("TargetPos")) //锁定目标 { targetPos = target.CurrentPos; attackDirection = (int)Global.GetDirectionByTan((int)targetPos.X, (int)targetPos.Y, owner.CurrentPos.X, owner.CurrentPos.Y); } else //鼠标指向 { targetPos = target.CurrentPos; attackDirection = (int)Global.GetDirectionByTan((int)targetPos.X, (int)targetPos.Y, owner.CurrentPos.X, owner.CurrentPos.Y); } List <Object> enemiesObjList = new List <Object>(); direction = attackDirection; if (magicScanTypeItem != null) { //矩形范围技 if (magicScanTypeItem.MagicActionID == MagicActionIDs.SCAN_SQUARE) { GameManager.ClientMgr.LookupRolesInSquare(owner.CurrentMapCode, owner.CopyMapID, (int)owner.CurrentPos.X, (int)owner.CurrentPos.Y, (int)targetPos.X, (int)targetPos.Y, (int)magicScanTypeItem.MagicActionParams[0], (int)magicScanTypeItem.MagicActionParams[1], enemiesObjList); } else if (magicScanTypeItem.MagicActionID == MagicActionIDs.FRONT_SECTOR) { GameManager.ClientMgr.LookupEnemiesInCircleByAngle((int)attackDirection, owner.CurrentMapCode, owner.CopyMapID, (int)targetPos.X, (int)targetPos.Y, Global.SafeConvertToInt32(systemMagic.GetStringValue("AttackDistance")), enemiesObjList, magicScanTypeItem.MagicActionParams[0], true); } // 以前没有加对圆形的判断 导致竞技场ai无法释放群攻圆形的技能 else if (magicScanTypeItem.MagicActionID == MagicActionIDs.ROUNDSCAN) // 增加对圆形的判断 [XSea 2015/5/21] { GameManager.ClientMgr.LookupEnemiesInCircle(owner.CurrentMapCode, owner.CopyMapID, (int)owner.CurrentPos.X, (int)owner.CurrentPos.Y, (int)Global.SafeConvertToInt32(systemMagic.GetStringValue("AttackDistance")), enemiesObjList); } } else { GameManager.ClientMgr.LookupEnemiesInCircle(owner.CurrentMapCode, owner.CopyMapID, (int)targetPos.X, (int)targetPos.Y, Global.SafeConvertToInt32(systemMagic.GetStringValue("AttackDistance")), enemiesObjList); } if (enemiesObjList.Count <= 0) { return(false); } for (int i = 0; i < enemiesObjList.Count; i++) { if ((enemiesObjList[i] as GameClient).ClientData.RoleID == target.GetObjectID()) { return(true); } } } return(false); }
public bool ProcessZhuanPanChouJiangCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams) { try { if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 2)) { return(false); } int roleID = Convert.ToInt32(cmdParams[0]); int awardType = Convert.ToInt32(cmdParams[1]); DateTime now = TimeUtil.NowDateTime(); ZhuanPanChouJiangData data = new ZhuanPanChouJiangData(); List <ZhuanPanItem> zhuanPanList = new List <ZhuanPanItem>(); int awardID = 0; int binding = 1; data.AwardType = awardType; lock (ZhuanPanManager.ZhuanPanRunTimeData.Mutex) { int addHours = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanFree; int moneyTypeIndex = awardType - 1; if (moneyTypeIndex < 0 || moneyTypeIndex >= ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanConstArray.Count) { data.Result = -200; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } int moneyType = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanConstArray[moneyTypeIndex][0]; int subMoney = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanConstArray[moneyTypeIndex][1]; if (moneyType <= 0 || subMoney <= 0) { data.Result = -200; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } int fuLiCount = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanZuanShiFuLi; Dictionary <int, Dictionary <int, ZhuanPanAwardItem> > zhuanPanAwardDict = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanAwardXmlDict; zhuanPanList = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanItemXmlList; if (now < ZhuanPanManager.ZhuanPanRunTimeData.BeginTime || now > ZhuanPanManager.ZhuanPanRunTimeData.EndTime) { data.Result = -100; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } DateTime chouJiangTime = Global.GetRoleParamsDateTimeFromDB(client, "10165"); if (chouJiangTime < ZhuanPanManager.ZhuanPanRunTimeData.BeginTime) { chouJiangTime = ZhuanPanManager.ZhuanPanRunTimeData.BeginTime; Global.SaveRoleParamsDateTimeToDB(client, "10165", chouJiangTime, true); Global.SaveRoleParamsInt32ValueToDB(client, "10162", 0, true); } DateTime nextChouJiang = DateTime.MaxValue; if (addHours > 0) { nextChouJiang = Global.GetRoleParamsDateTimeFromDB(client, "10155").AddHours((double)addHours); } if (!Global.CanAddGoodsNum(client, 1) || !RebornEquip.CanAddGoodsNum(client, 1)) { data.Result = -4; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } awardID = Global.GetRoleParamsInt32FromDB(client, "10162"); if (awardID > 0) { data.Result = -202; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } Dictionary <int, ZhuanPanAwardItem> zhuanPanAwardItemDict = null; if (!zhuanPanAwardDict.TryGetValue(awardType, out zhuanPanAwardItemDict)) { data.Result = -101; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } int roleFuliCout = Global.GetRoleParamsInt32FromDB(client, "10156"); data.LeftFuLiCount = roleFuliCout; data.FreeTime = nextChouJiang; bool free = false; if (awardType == 3) { if (!zhuanPanAwardDict.ContainsKey(4)) { data.Result = -101; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } if (now > nextChouJiang) { data.FreeTime = now.AddHours((double)addHours); free = true; } } if (!free) { if (!MoneyUtil.CheckHasMoney(client, moneyType, subMoney)) { data.Result = -awardType; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } string strCostList = ""; if (!MoneyUtil.CostMoney(client, moneyType, subMoney, ref strCostList, "转盘抽奖", true)) { data.Result = -awardType; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } } if (awardType == 3) { if (now > nextChouJiang) { Global.SaveRoleParamsDateTimeToDB(client, "10155", now, true); data.FreeTime = now.AddHours((double)addHours); } else { binding = 0; roleFuliCout--; if (roleFuliCout < 1) { if (!zhuanPanAwardDict.TryGetValue(4, out zhuanPanAwardItemDict)) { data.Result = -101; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } roleFuliCout = fuLiCount; awardType = 4; } if (roleFuliCout > ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanZuanShiFuLi) { roleFuliCout = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanZuanShiFuLi; } Global.SaveRoleParamsInt32ValueToDB(client, "10156", roleFuliCout, true); data.LeftFuLiCount = roleFuliCout; } } int random = Global.GetRandomNumber(1, 100000); foreach (KeyValuePair <int, ZhuanPanAwardItem> item in zhuanPanAwardItemDict) { if (random >= item.Value.StartValue && random <= item.Value.EndValue) { awardID = item.Key; } } if (zhuanPanList.Count < awardID || awardID <= 0) { LogManager.WriteLog(LogTypes.Fatal, string.Format("转盘抽奖随机出的awardID={0}找不到对应的奖励配置", awardID), null, true); data.Result = -201; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } data.Result = 1; ZhuanPanItem award = zhuanPanList[awardID - 1]; SystemXmlItem systemGoods = null; int goodID = Convert.ToInt32(award.GoodsID.Split(new char[] { ',' })[0]); if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodID, out systemGoods)) { LogManager.WriteLog(LogTypes.Fatal, string.Format("转盘抽奖随机出的goodID={0}道具表中不存在", goodID), null, true); string strinfo = string.Format("系统中不存在{0}", goodID); GameManager.ClientMgr.SendSystemChatMessageToClient(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, strinfo); data.Result = -201; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); return(true); } string goodName = systemGoods.GetStringValue("Title"); if (awardType == 3 && binding > 0) { awardType = 4; } GameManager.logDBCmdMgr.AddDBLogInfo(-1, goodName, "转盘抽奖_类型:" + awardType, client.ClientData.RoleName, "系统", "修改", -1, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null); string[] goods = award.GoodsID.Split(new char[] { ',' }); goods[2] = binding.ToString(); data.GoodsItem = new ZhuanPanItem { ID = award.ID, GoodsID = string.Join(",", goods), AwardLevel = award.AwardLevel, GongGao = award.GongGao, AwardLabel = award.AwardLevel }; } Global.SaveRoleParamsInt32ValueToDB(client, "10162", awardID, true); Global.SaveRoleParamsDateTimeToDB(client, "10165", now, true); Global.SaveRoleParamsInt32ValueToDB(client, "10166", binding, true); data.AwardType = awardType; client.sendCmd <ZhuanPanChouJiangData>(nID, data, false); client._IconStateMgr.CheckFreeZhuanPanChouState(client); client._IconStateMgr.SendIconStateToClient(client); return(true); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false); } return(false); }
public void InitSkill() { //InitExcel(); // return; XElement szxXml = null; try { string fullPathFileName = Logic.Global.GameResPath(SkillPathName); szxXml = XElement.Load(fullPathFileName); if (null == szxXml) { throw new Exception(string.Format("加载技能xml配置文件:{0}, 失败。没有找到相关XML配置文件!", fullPathFileName)); } SystemXmlItem systemXmlItem = new SystemXmlItem(); IEnumerable <XElement> nodes = szxXml.Elements(SkillRootName).Elements(); foreach (var node in nodes) { systemXmlItem.XMLNode = node; SkillObject skillObject = new SkillObject() { SkillID = systemXmlItem.GetIntValue("SkillID"), SkillName = systemXmlItem.GetStringValue("Name"), Remark = systemXmlItem.GetStringValue("Remark"), NeedMP = systemXmlItem.GetIntValue("NeedMP"), NeedHP = systemXmlItem.GetIntValue("NeedHP"), SkillType = systemXmlItem.GetIntValue("SkillType"), Distance = systemXmlItem.GetIntValue("Distance"), CDTime = systemXmlItem.GetIntValue("Cooling"), HarmType = systemXmlItem.GetIntValue("HarmType"), Occupation = systemXmlItem.GetIntValue("NeedJob"), HardHarm = systemXmlItem.GetIntValue("HardHarm"), NeedLV = systemXmlItem.GetIntValue("NeedLV"), SkillLevel = systemXmlItem.GetIntValue("SkillLevel"), Ballistic = systemXmlItem.GetIntValue("Ballistic"), NeedSkill = null, BecomeNeedSkill = null, NextSkill = null, BecomeNextSkill = null, BuffList = null, EffectList = null, RangeType = null, NeedWeapons = null, SkillHarmList = null, TargetType = systemXmlItem.GetIntValue("TargetType") }; //务器类型 skillObject.NeedWeapons = new List <int>(); string[] szNeedWeapons = systemXmlItem.GetStringValue("NeedWeapons").Split('#'); foreach (var s in szNeedWeapons) { skillObject.NeedWeapons.Add(Convert.ToInt32(s)); } //前置技能 skillObject.NeedSkill = new List <int>(); string[] szNeedSkill = systemXmlItem.GetStringValue("NeedSkill").Split('#'); foreach (var s in szNeedSkill) { skillObject.NeedSkill.Add(Convert.ToInt32(s)); } //开化后前置技能 skillObject.BecomeNeedSkill = new List <int>(); string[] szBecomeNeedSkill = systemXmlItem.GetStringValue("BecomeNeedSkill").Split('#'); foreach (var s in szBecomeNeedSkill) { skillObject.BecomeNeedSkill.Add(Convert.ToInt32(s)); } //后置技能 skillObject.NextSkill = new List <int>(); string[] szNextSkill = systemXmlItem.GetStringValue("NextSkill").Split('#'); foreach (var s in szNextSkill) { skillObject.NextSkill.Add(Convert.ToInt32(s)); } //开花后得后置技能 skillObject.BecomeNextSkill = new List <int>(); string[] szBecomeNextSkill = systemXmlItem.GetStringValue("BecomeNextSkill").Split('#'); foreach (var s in szBecomeNextSkill) { skillObject.BecomeNextSkill.Add(Convert.ToInt32(s)); } //影响范围 skillObject.RangeType = new List <int>(); string[] szRangeType = systemXmlItem.GetStringValue("RangeType").Split('#'); foreach (var s in szRangeType) { skillObject.RangeType.Add(Convert.ToInt32(s)); } //技能伤害 skillObject.SkillHarmList = new List <int>(); string[] szSkillHarm = systemXmlItem.GetStringValue("SkillHarm").Split('#'); foreach (var s in szSkillHarm) { skillObject.SkillHarmList.Add(Convert.ToInt32(s)); } //释放目标 //skillObject.TargetTypeList = new List<int>(); //string[] szTargetType = systemXmlItem.GetStringValue("TargetType").Split('#'); //foreach (var s in szTargetType) //{ // skillObject.TargetTypeList.Add(Convert.ToInt32(s)); //} //释放类型 skillObject.ReleaseTypeList = new List <int>(); string[] szReleaseType = systemXmlItem.GetStringValue("ReleaseType").Split('#'); foreach (var s in szSkillHarm) { skillObject.ReleaseTypeList.Add(Convert.ToInt32(s)); } SystemSkillList.Add(skillObject.SkillID, skillObject); //SysConOut.WriteLine(string.Format("加载技能配置文件:{0},", skillObject.SkillID)); } } catch (Exception ex) { SysConOut.WriteLine(string.Format("加载技能Excel配置文件:{0}, 失败。没有找到相关XML配置文件[{1}]!", SkillPathName, ex.Message)); // throw new Exception(string.Format("加载技能xxml配置文件:{0}, 失败。没有找到相关XML配置文件!", SkillPathName)); } SysConOut.WriteLine(string.Format("加载技能配置文件:{0},", SystemSkillList.Count)); }
public bool processCmd(GameClient client, string[] cmdParams) { int roleID = Global.SafeConvertToInt32(cmdParams[0]); int bhid = Global.SafeConvertToInt32(cmdParams[1]); int buildType = Global.SafeConvertToInt32(cmdParams[2]); int toLevel = Math.Max(2, Global.SafeConvertToInt32(cmdParams[3])); int nID = (int)TCPGameServerCmds.CMD_SPR_ZHANMENGBUILDUPLEVEL; string strcmd = ""; if (client.ClientData.Faction != bhid) { strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", -1, roleID, bhid, buildType, 0); client.sendCmd(nID, strcmd); return(true); } if (toLevel > Global.MaxBangHuiFlagLevel) { strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", -2, roleID, bhid, buildType, 0); client.sendCmd(nID, strcmd); return(true); } SystemXmlItem systemZhanMengBuildItem = Global.GetZhanMengBuildItem(buildType, toLevel); if (null == systemZhanMengBuildItem) { strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", -3, roleID, bhid, buildType, 0); client.sendCmd(nID, strcmd); return(true); } int levelupCost = systemZhanMengBuildItem.GetIntValue("LevelupCost"); String strReqGoods = systemZhanMengBuildItem.GetStringValue("NeedGoods"); string dbcmd = string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}", roleID, bhid, buildType, levelupCost, toLevel, Global.GetZhanMengInitCoin(), strReqGoods); string[] fields = Global.ExecuteDBCmd(nID, dbcmd, client.ServerId); if (null == fields || fields.Length != 1) { LogManager.WriteLog(LogTypes.Error, string.Format("升级帮旗等级时失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(client.ClientSocket), roleID)); return(false); } int retCode = Global.SafeConvertToInt32(fields[0]); if (retCode >= 0) { //帮旗升级的提示 Global.BroadcastZhanMengBuildUpLevelHint(client, buildType, toLevel); strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", toLevel, roleID, bhid, buildType, levelupCost); //通知GameServer同步帮会的所属和范围 JunQiManager.NotifySyncBangHuiJunQiItemsDict(client); GameManager.ClientMgr.NotifyBangHuiUpLevel(bhid, client.ServerId, toLevel, client.ClientSocket.IsKuaFuLogin); } else { strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", retCode, roleID, bhid, buildType, 0); } client.sendCmd(nID, strcmd); return(true); }
/// <summary> /// 翅膀升星处理 /// </summary> public bool processCmd(Logic.GameClient client, string[] cmdParams) { //int nID = (int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR; int nRoleID = Global.SafeConvertToInt32(cmdParams[0]); int nUpStarMode = Global.SafeConvertToInt32(cmdParams[1]); //0: 道具升星, 1: 钻石升星 //string strCmd = ""; SCWingStarUp scData = null; if (null == client.ClientData.MyWingData) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } // 获取升星信息表 SystemXmlItem upStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel + 1); if (null == upStarXmlItem) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(StdErrorCode.Error_Level_Reach_Max_Level, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } string strWingShengXing = GameManager.systemParamsList.GetParamValueByName("WingShengXing"); if ("" == strWingShengXing) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } // 解析升级暴率 string[] wingShengXing = strWingShengXing.Split(','); if (3 != wingShengXing.Length) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } // 暴率 int nPowRate = 0; // 增加的星经验 int nAddExp = 0; if (0 == nUpStarMode) { nPowRate = (int)(Convert.ToDouble(wingShengXing[0]) * 100.0); nAddExp = Convert.ToInt32(upStarXmlItem.GetIntValue("GoodsExp")); } else { nPowRate = (int)(Convert.ToDouble(wingShengXing[1]) * 100.0); nAddExp = Convert.ToInt32(upStarXmlItem.GetIntValue("ZuanShiExp")); } // 暴升,乘以经验倍数 int nRandNum = Global.GetRandomNumber(0, 100); if (nRandNum < nPowRate) { nAddExp *= Convert.ToInt32(wingShengXing[2]); } int nUpStarReqExp = upStarXmlItem.GetIntValue("StarExp"); int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarExp = 0; if (client.ClientData.MyWingData.StarExp + nAddExp >= nUpStarReqExp) { if (nNextStarLevel < MUWingsManager.MaxWingEnchanceLevel) { // 改变星级,剩余的经验改到下级 nNextStarLevel += 1; nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp - nUpStarReqExp; // 连续升星 while (true) { if (nNextStarLevel >= MUWingsManager.MaxWingEnchanceLevel) { break; } SystemXmlItem nextStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, nNextStarLevel + 1); if (null == upStarXmlItem) { break; } int nNextUpStarReqExp = nextStarXmlItem.GetIntValue("StarExp"); if (nNextStarExp >= nNextUpStarReqExp) { nNextStarLevel += 1; nNextStarExp = nNextStarExp - nNextUpStarReqExp; } else { break; } } } else { // 已经达到最高星 nNextStarExp = nUpStarReqExp; } } else { nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp; } if (0 == nUpStarMode) { //获取强化需要的道具的物品ID string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods"); // 解析物品ID与数量 string[] itemParams = strReqItemID.Split(','); if (null == itemParams || itemParams.Length != 2) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } int originGoodsID = Convert.ToInt32(itemParams[0]); int originGoodsNum = Convert.ToInt32(itemParams[1]); if (originGoodsID <= 0 || originGoodsNum <= 0) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } GoodsReplaceResult replaceRet = GoodsReplaceManager.Instance().GetReplaceResult(client, originGoodsID); if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum) { // 物品数量不够 //strCmd = string.Format("{0}:{1}:{2}:{3}", -4, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-4, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>(); // 1:替换后的绑定材料 // 2:替换后的非绑定材料 // 3:原始绑定材料 // 4:原始非绑定材料 realCostList.AddRange(replaceRet.BindList); realCostList.AddRange(replaceRet.UnBindList); realCostList.Add(replaceRet.OriginBindGoods); realCostList.Add(replaceRet.OriginUnBindGoods); int hasUseCnt = 0; int stillNeedCnt = originGoodsNum; foreach (var item in realCostList) { if (item.GoodsCnt <= 0) { continue; } int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt); if (realCostCnt <= 0) { break; } bool bUsedBinding = false; bool bUsedTimeLimited = false; bool bFailed = false; if (item.IsBind) { if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited)) { bFailed = true; } } else { if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited)) { bFailed = true; } } stillNeedCnt -= realCostCnt; if (bFailed) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -5, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-5, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } } } else { // 获取强化需要的钻石数量 int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi"); if (nReqZuanShi <= 0) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } //判断用户点卷额是否不足【钻石】 if (client.ClientData.UserMoney < nReqZuanShi) { //用户点卷额不足【钻石】 //strCmd = string.Format("{0}:{1}:{2}:{3}", -6, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-6, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } //先DBServer请求扣费 //扣除用户点卷 if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀升星")) { //扣除用户点卷失败 //strCmd = string.Format("{0}:{1}:{2}:{3}", -7, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-7, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } } // 七日活动 // 翅膀升级和升阶次数,成功失败都算 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes)); // 将改变保存到数据库 int iRet = MUWingsManager.WingUpStarDBCommand(client, client.ClientData.MyWingData.DbID, nNextStarLevel, nNextStarExp); if (iRet < 0) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } else { //strCmd = string.Format("{0}:{1}:{2}:{3}", 0, nRoleID, nNextStarLevel, nNextStarExp); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(0, nRoleID, nNextStarLevel, nNextStarExp); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); client.ClientData.MyWingData.StarExp = nNextStarExp; if (client.ClientData.MyWingData.ForgeLevel != nNextStarLevel) { // 先移除原来的属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, false); } bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu); client.ClientData.MyWingData.ForgeLevel = nNextStarLevel; // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel)); bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu); if (!oldWingLingYuOpened && newWingLingYuOpened) { // 翎羽功能开启了,执行初始化 LingYuManager.InitAsOpened(client); } // 按新等级增加属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, true); //升星时候,翅膀的基础属性的改变会影响注魂加成 ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } //[bing] 刷新客户端活动叹号 if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing) || client._IconStateMgr.CheckSpecialActivity(client)) { client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived()); client._IconStateMgr.SendIconStateToClient(client); } } } return(true); }
private bool testAttackDistance(out int direction) { direction = 0; SystemXmlItem systemMagic = null; bool result; if (!GameManager.SystemMagicsMgr.SystemXmlItemDict.TryGetValue(this.skillId, out systemMagic)) { result = false; } else { List <MagicActionItem> magicScanTypeItemList = null; if (!GameManager.SystemMagicScanTypeMgr.MagicActionsDict.TryGetValue(this.skillId, out magicScanTypeItemList) || null == magicScanTypeItemList) { } List <MagicActionItem> magicActionItemList = null; if (!GameManager.SystemMagicActionMgr.MagicActionsDict.TryGetValue(this.skillId, out magicActionItemList) || null == magicActionItemList) { result = false; } else { MagicActionItem magicScanTypeItem = null; if (magicScanTypeItemList != null && magicScanTypeItemList.Count > 0) { magicScanTypeItem = magicScanTypeItemList[0]; } int attackDistance = systemMagic.GetIntValue("AttackDistance", -1); if (systemMagic.GetIntValue("MagicType", -1) == 1 || systemMagic.GetIntValue("MagicType", -1) == 3) { int targetType = systemMagic.GetIntValue("TargetType", -1); if (1 == targetType) { return(true); } if (this.skillId == 11004 && 4 == targetType) { return(true); } if (2 == targetType) { return(false); } } else { int attackDirection = 0; Point targetPos; if (1 == systemMagic.GetIntValue("TargetPos", -1)) { targetPos = this.owner.CurrentPos; } else if (2 == systemMagic.GetIntValue("TargetPos", -1)) { targetPos = this.target.CurrentPos; attackDirection = (int)Global.GetDirectionByTan((double)((int)targetPos.X), (double)((int)targetPos.Y), this.owner.CurrentPos.X, this.owner.CurrentPos.Y); } else { targetPos = this.target.CurrentPos; attackDirection = (int)Global.GetDirectionByTan((double)((int)targetPos.X), (double)((int)targetPos.Y), this.owner.CurrentPos.X, this.owner.CurrentPos.Y); } List <object> enemiesObjList = new List <object>(); direction = attackDirection; if (magicScanTypeItem != null) { if (magicScanTypeItem.MagicActionID == MagicActionIDs.SCAN_SQUARE) { GameManager.ClientMgr.LookupRolesInSquare(this.owner.CurrentMapCode, this.owner.CopyMapID, (int)this.owner.CurrentPos.X, (int)this.owner.CurrentPos.Y, (int)targetPos.X, (int)targetPos.Y, (int)magicScanTypeItem.MagicActionParams[0], (int)magicScanTypeItem.MagicActionParams[1], enemiesObjList); } else if (magicScanTypeItem.MagicActionID == MagicActionIDs.FRONT_SECTOR) { GameManager.ClientMgr.LookupEnemiesInCircleByAngle(attackDirection, this.owner.CurrentMapCode, this.owner.CopyMapID, (int)targetPos.X, (int)targetPos.Y, Global.SafeConvertToInt32(systemMagic.GetStringValue("AttackDistance")), enemiesObjList, magicScanTypeItem.MagicActionParams[0], true); } else if (magicScanTypeItem.MagicActionID == MagicActionIDs.ROUNDSCAN) { GameManager.ClientMgr.LookupEnemiesInCircle(this.owner.CurrentMapCode, this.owner.CopyMapID, (int)this.owner.CurrentPos.X, (int)this.owner.CurrentPos.Y, Global.SafeConvertToInt32(systemMagic.GetStringValue("AttackDistance")), enemiesObjList); } } else { GameManager.ClientMgr.LookupEnemiesInCircle(this.owner.CurrentMapCode, this.owner.CopyMapID, (int)targetPos.X, (int)targetPos.Y, Global.SafeConvertToInt32(systemMagic.GetStringValue("AttackDistance")), enemiesObjList); } if (enemiesObjList.Count <= 0) { return(false); } for (int i = 0; i < enemiesObjList.Count; i++) { if ((enemiesObjList[i] as GameClient).ClientData.RoleID == this.target.GetObjectID()) { return(true); } } } result = false; } } return(result); }
public bool processCmd(GameClient client, string[] cmdParams) { int nRoleID = Global.SafeConvertToInt32(cmdParams[0]); int nUpStarMode = Global.SafeConvertToInt32(cmdParams[1]); string strCostList = ""; bool result; if (null == client.ClientData.MyWingData) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); result = true; } else { SystemXmlItem upStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel + 1); if (null == upStarXmlItem) { SCWingStarUp scData = new SCWingStarUp(-23, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); result = true; } else { string strWingShengXing = GameManager.systemParamsList.GetParamValueByName("WingShengXing"); if ("" == strWingShengXing) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); result = true; } else { string[] wingShengXing = strWingShengXing.Split(new char[] { ',' }); if (3 != wingShengXing.Length) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); result = true; } else { int nAddExp = 0; int nPowRate; if (0 == nUpStarMode) { nPowRate = (int)(Convert.ToDouble(wingShengXing[0]) * 100.0); nAddExp = Convert.ToInt32(upStarXmlItem.GetIntValue("GoodsExp", -1)); } else { nPowRate = (int)(Convert.ToDouble(wingShengXing[1]) * 100.0); nAddExp = Convert.ToInt32(upStarXmlItem.GetIntValue("ZuanShiExp", -1)); } int nRandNum = Global.GetRandomNumber(0, 100); if (nRandNum < nPowRate) { nAddExp *= Convert.ToInt32(wingShengXing[2]); } int nUpStarReqExp = upStarXmlItem.GetIntValue("StarExp", -1); int nOldStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarExp = 0; if (client.ClientData.MyWingData.StarExp + nAddExp >= nUpStarReqExp) { if (nNextStarLevel < MUWingsManager.MaxWingEnchanceLevel) { nNextStarLevel++; nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp - nUpStarReqExp; while (nNextStarLevel < MUWingsManager.MaxWingEnchanceLevel) { SystemXmlItem nextStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, nNextStarLevel + 1); if (null != upStarXmlItem) { int nNextUpStarReqExp = nextStarXmlItem.GetIntValue("StarExp", -1); if (nNextStarExp >= nNextUpStarReqExp) { nNextStarLevel++; nNextStarExp -= nNextUpStarReqExp; continue; } } break; } } else { nNextStarExp = nUpStarReqExp; } } else { nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp; } if (0 == nUpStarMode) { string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods"); string[] itemParams = strReqItemID.Split(new char[] { ',' }); if (itemParams == null || itemParams.Length != 2) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } int originGoodsID = Convert.ToInt32(itemParams[0]); int originGoodsNum = Convert.ToInt32(itemParams[1]); if (originGoodsID <= 0 || originGoodsNum <= 0) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } GoodsReplaceResult replaceRet = SingletonTemplate <GoodsReplaceManager> .Instance().GetReplaceResult(client, originGoodsID); if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum) { SCWingStarUp scData = new SCWingStarUp(-4, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>(); realCostList.AddRange(replaceRet.BindList); realCostList.AddRange(replaceRet.UnBindList); realCostList.Add(replaceRet.OriginBindGoods); realCostList.Add(replaceRet.OriginUnBindGoods); int stillNeedCnt = originGoodsNum; foreach (GoodsReplaceResult.ReplaceItem item in realCostList) { if (item.GoodsCnt > 0) { int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt); if (realCostCnt <= 0) { break; } bool bUsedBinding = false; bool bUsedTimeLimited = false; bool bFailed = false; if (item.IsBind) { if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited, false)) { bFailed = true; } } else if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited, false)) { bFailed = true; } stillNeedCnt -= realCostCnt; if (bFailed) { SCWingStarUp scData = new SCWingStarUp(-5, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } GoodsData goodsData = new GoodsData { GoodsID = item.GoodsID, GCount = realCostCnt }; strCostList = EventLogManager.NewGoodsDataPropString(goodsData); } } } else { int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi", -1); if (nReqZuanShi <= 0) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } if (client.ClientData.UserMoney < nReqZuanShi) { SCWingStarUp scData = new SCWingStarUp(-6, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } int oldUserMoney = client.ClientData.UserMoney; int oldUserGlod = client.ClientData.Gold; if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀升星", true, true, false, DaiBiSySType.ChiBangShengXing)) { SCWingStarUp scData = new SCWingStarUp(-7, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } strCostList = EventLogManager.NewResPropString(ResLogType.FristBindZuanShi, new object[] { -nReqZuanShi, oldUserGlod, client.ClientData.Gold, oldUserMoney, client.ClientData.UserMoney }); } GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes)); int iRet = MUWingsManager.WingUpStarDBCommand(client, client.ClientData.MyWingData.DbID, nNextStarLevel, nNextStarExp); if (iRet < 0) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); result = true; } else { SCWingStarUp scData = new SCWingStarUp(0, nRoleID, nNextStarLevel, nNextStarExp); client.sendCmd <SCWingStarUp>(608, scData, false); client.ClientData.MyWingData.StarExp = nNextStarExp; if (client.ClientData.MyWingData.ForgeLevel != nNextStarLevel) { if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, false); } bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false); client.ClientData.MyWingData.ForgeLevel = nNextStarLevel; GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel)); bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false); if (!oldWingLingYuOpened && newWingLingYuOpened) { LingYuManager.InitAsOpened(client); } if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, true); ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7); } if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing) || client._IconStateMgr.CheckSpecialActivity(client) || client._IconStateMgr.CheckEverydayActivity(client) || client._IconStateMgr.CheckReborn(client)) { client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived()); client._IconStateMgr.SendIconStateToClient(client); } } EventLogManager.AddWingStarEvent(client, nUpStarMode, nAddExp, nOldStarLevel, client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel, client.ClientData.MyWingData.StarExp, strCostList); ProcessTask.ProcessRoleTaskVal(client, TaskTypes.WingIDLevel, -1); result = true; } } } } } return(result); }
public bool processCmd(Logic.GameClient client, string[] cmdParams) { int nID = (int)TCPGameServerCmds.CMD_SPR_WINGUPGRADE; int nRoleID = Global.SafeConvertToInt32(cmdParams[0]); int nUpWingMode = Global.SafeConvertToInt32(cmdParams[1]); //0: 道具进阶, 1: 钻石进阶 string strCmd = ""; if (null == client.ClientData.MyWingData) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 已到最高级 if (client.ClientData.MyWingData.WingID >= MUWingsManager.MaxWingID) { strCmd = string.Format("{0}:{1}:{2}:{3}", -8, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 获取进阶信息表 SystemXmlItem upStarXmlItem = MUWingsManager.GetWingUPCacheItem(client.ClientData.MyWingData.WingID + 1); if (null == upStarXmlItem) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } if (0 == nUpWingMode) { // 获取进阶需要的道具的物品信息 string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods"); // 解析物品ID与数量 string[] itemParams = strReqItemID.Split(','); if (null == itemParams || itemParams.Length != 2) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 获取进阶需要的道具的物品ID int nEnchanceNeedGoodsID = Convert.ToInt32(itemParams[0]); // 获取进阶需要的道具的物品数量 int nEnchanceNeedGoodsNum = Convert.ToInt32(itemParams[1]); if (nEnchanceNeedGoodsID <= 0 || nEnchanceNeedGoodsNum <= 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 判断数量是否够 if (Global.GetTotalGoodsCountByID(client, nEnchanceNeedGoodsID) < nEnchanceNeedGoodsNum) { // 物品数量不够 strCmd = string.Format("{0}:{1}:{2}:{3}", -4, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 自动扣除物品 if (nEnchanceNeedGoodsNum > 0) { bool bUsedBinding = false; bool bUsedTimeLimited = false; //扣除物品 if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nEnchanceNeedGoodsID, nEnchanceNeedGoodsNum, false, out bUsedBinding, out bUsedTimeLimited)) { strCmd = string.Format("{0}:{1}:{2}:{3}", -5, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } } } else { // 获取进阶需要的钻石数量 int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi"); if (nReqZuanShi <= 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 判断用户点卷额是否不足【钻石】 if (client.ClientData.UserMoney < nReqZuanShi) { //用户点卷额不足【钻石】 strCmd = string.Format("{0}:{1}:{2}:{3}", -6, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } //先DBServer请求扣费 //扣除用户点卷 if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀进阶")) { //扣除用户点卷失败 strCmd = string.Format("{0}:{1}:{2}:{3}", -7, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } } int nLuckOne = upStarXmlItem.GetIntValue("LuckyOne"); int nLuckyTwo = upStarXmlItem.GetIntValue("LuckyTwo"); int nLuckTwoRate = (int)(upStarXmlItem.GetDoubleValue("LuckyTwoRate") * 100.0); int nNextWingID = client.ClientData.MyWingData.WingID; int nNextJinJieFailedNum = client.ClientData.MyWingData.JinJieFailedNum; int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarExp = client.ClientData.MyWingData.StarExp; // LuckyOne+提升获得幸运点 < LuckyTwo;必定不会提升成功 if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < nLuckyTwo) { // 幸运点加1 nNextJinJieFailedNum++; } // LuckyOne+提升获得幸运点>= LuckyTwo,则根据配置得到LuckyTwoRate概率判定是否能够完成进阶操作 else if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < 110000) { // int nRandNum = Global.GetRandomNumber(0, 100); if (nRandNum < nLuckTwoRate) { // 进阶成功 nNextWingID++; // 幸运点清0 nNextJinJieFailedNum = 0; // 星级清0 nNextStarLevel = 0; // 星级经验清0 nNextStarExp = 0; } else { // 幸运点加1 nNextJinJieFailedNum++; } } // LuckyOne+提升获得幸运点>=110000时,进阶必定成功 else { // 进阶成功 nNextWingID++; // 幸运点清0 nNextJinJieFailedNum = 0; // 星级清0 nNextStarLevel = 0; // 星级经验清0 nNextStarExp = 0; } // 将改变保存到数据库 int iRet = MUWingsManager.WingUpDBCommand(client, client.ClientData.MyWingData.DbID, nNextWingID, nNextJinJieFailedNum, nNextStarLevel, nNextStarExp); if (iRet < 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } else { strCmd = string.Format("{0}:{1}:{2}:{3}", 0, nRoleID, nNextWingID, nNextJinJieFailedNum); client.sendCmd(nID, strCmd); client.ClientData.MyWingData.JinJieFailedNum = nNextJinJieFailedNum; if (client.ClientData.MyWingData.WingID != nNextWingID) { // 先移除原来的属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, false); } client.ClientData.MyWingData.WingID = nNextWingID; client.ClientData.MyWingData.ForgeLevel = 0; client.ClientData.MyWingData.StarExp = 0; // 按新等级增加属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, true); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } } } return(true); }
public bool processCmd(GameClient client, string[] cmdParams) { int nID = 609; int nRoleID = Global.SafeConvertToInt32(cmdParams[0]); int nUpWingMode = Global.SafeConvertToInt32(cmdParams[1]); bool result; if (null == client.ClientData.MyWingData) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); result = true; } else if (client.ClientData.MyWingData.WingID >= MUWingsManager.MaxWingID) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -8, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); result = true; } else { SystemXmlItem upStarXmlItem = MUWingsManager.GetWingUPCacheItem(client.ClientData.MyWingData.WingID + 1); if (null == upStarXmlItem) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); result = true; } else { SystemXmlItem upStarXmlItem2 = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel + 1); if (null != upStarXmlItem2) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); result = true; } else { string strCostList = ""; if (0 == nUpWingMode) { string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods"); string[] itemParams = strReqItemID.Split(new char[] { ',' }); if (itemParams == null || itemParams.Length != 2) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } int originGoodsID = Convert.ToInt32(itemParams[0]); int originGoodsNum = Convert.ToInt32(itemParams[1]); if (originGoodsID <= 0 || originGoodsNum <= 0) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } GoodsReplaceResult replaceRet = SingletonTemplate <GoodsReplaceManager> .Instance().GetReplaceResult(client, originGoodsID); if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -4, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>(); realCostList.AddRange(replaceRet.BindList); realCostList.AddRange(replaceRet.UnBindList); realCostList.Add(replaceRet.OriginBindGoods); realCostList.Add(replaceRet.OriginUnBindGoods); int stillNeedCnt = originGoodsNum; foreach (GoodsReplaceResult.ReplaceItem item in realCostList) { if (item.GoodsCnt > 0) { int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt); if (realCostCnt <= 0) { break; } bool bUsedBinding = false; bool bUsedTimeLimited = false; bool bFailed = false; if (item.IsBind) { if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited, false)) { bFailed = true; } } else if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited, false)) { bFailed = true; } stillNeedCnt -= realCostCnt; if (bFailed) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -5, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } GoodsData goodsDataLog = new GoodsData { GoodsID = item.GoodsID, GCount = realCostCnt }; strCostList = EventLogManager.NewGoodsDataPropString(goodsDataLog); } } } else { int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi", -1); if (nReqZuanShi <= 0) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } int oldUserMoney = client.ClientData.UserMoney; int oldUserGlod = client.ClientData.Gold; if (client.ClientData.UserMoney < nReqZuanShi && !HuanLeDaiBiManager.GetInstance().HuanledaibiEnough(client, nReqZuanShi)) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -6, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀进阶", true, true, false, DaiBiSySType.ChiBangShengJie)) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -7, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } strCostList = EventLogManager.NewResPropString(ResLogType.FristBindZuanShi, new object[] { -nReqZuanShi, oldUserGlod, client.ClientData.Gold, oldUserMoney, client.ClientData.UserMoney }); } int nLuckOne = upStarXmlItem.GetIntValue("LuckyOne", -1); int nLuckyTwo = upStarXmlItem.GetIntValue("LuckyTwo", -1); int nLuckTwoRate = (int)(upStarXmlItem.GetDoubleValue("LuckyTwoRate") * 100.0); int nNextWingID = client.ClientData.MyWingData.WingID; int nNextJinJieFailedNum = client.ClientData.MyWingData.JinJieFailedNum; int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarExp = client.ClientData.MyWingData.StarExp; int nOldWingID = client.ClientData.MyWingData.WingID; int nOldJinJieFailedNum = client.ClientData.MyWingData.JinJieFailedNum; int nOldStarLevel = client.ClientData.MyWingData.ForgeLevel; int nOldStarExp = client.ClientData.MyWingData.StarExp; if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < nLuckyTwo) { nNextJinJieFailedNum++; } else if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < 110000) { int nRandNum = Global.GetRandomNumber(0, 100); if (nRandNum < nLuckTwoRate) { nNextWingID++; nNextJinJieFailedNum = 0; nNextStarLevel = 0; nNextStarExp = 0; } else { nNextJinJieFailedNum++; } } else { nNextWingID++; nNextJinJieFailedNum = 0; nNextStarLevel = 0; nNextStarExp = 0; } GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes)); int iRet = MUWingsManager.WingUpDBCommand(client, client.ClientData.MyWingData.DbID, nNextWingID, nNextJinJieFailedNum, nNextStarLevel, nNextStarExp, client.ClientData.MyWingData.ZhuLingNum, client.ClientData.MyWingData.ZhuHunNum); if (iRet < 0) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); result = true; } else { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { 0, nRoleID, nNextWingID, nNextJinJieFailedNum }); client.sendCmd(nID, strCmd, false); client.ClientData.MyWingData.JinJieFailedNum = nNextJinJieFailedNum; if (client.ClientData.MyWingData.WingID != nNextWingID) { if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, false); } bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false); client.ClientData.MyWingData.WingID = nNextWingID; client.ClientData.MyWingData.ForgeLevel = 0; client.ClientData.MyWingData.StarExp = 0; GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel)); bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false); if (!oldWingLingYuOpened && newWingLingYuOpened) { LingYuManager.InitAsOpened(client); } if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, true); ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7); } if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing) || client._IconStateMgr.CheckReborn(client)) { client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived()); client._IconStateMgr.SendIconStateToClient(client); } EventLogManager.AddWingStarEvent(client, 2, 0, nOldStarLevel, client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel, client.ClientData.MyWingData.StarExp, strCostList); } EventLogManager.AddWingUpgradeEvent(client, nUpWingMode, nOldJinJieFailedNum, client.ClientData.MyWingData.JinJieFailedNum, nOldWingID, client.ClientData.MyWingData.WingID, nOldStarLevel, client.ClientData.MyWingData.ForgeLevel, nOldStarExp, client.ClientData.MyWingData.StarExp, strCostList); ProcessTask.ProcessRoleTaskVal(client, TaskTypes.WingIDLevel, -1); result = true; } } } } return(result); }