public bool ProcessShenJiAddExpCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams) { try { int result = 0; int roleID = Convert.ToInt32(cmdParams[0]); if (GameManager.ClientMgr.GetShenJiJiFenValue(client) <= 0) { result = 4; client.sendCmd(nID, string.Format("{0}:{1}", result, roleID), false); return(true); } ShenJiPointConfigData PointConfig = this.GetShenJiPointConfigInfo(client); if (null == PointConfig) { result = 6; client.sendCmd(nID, string.Format("{0}:{1}", result, roleID), false); return(true); } if (Global.GetUnionLevel2(client.ClientData.ChangeLifeCount, client.ClientData.Level) < PointConfig.NeedLevel) { result = 7; client.sendCmd(nID, string.Format("{0}:{1}", result, roleID), false); return(true); } int CurJiFen = GameManager.ClientMgr.GetShenJiJiFenValue(client); int JiFenAdd = GameManager.ClientMgr.GetShenJiJiFenAddValue(client); int CurNeedJiFen = PointConfig.NeedJiFen - JiFenAdd; if (CurJiFen >= CurNeedJiFen) { GameManager.ClientMgr.ModifyShenJiJiFenValue(client, -CurNeedJiFen, "精灵神迹积分注入", true, true); GameManager.ClientMgr.ModifyShenJiJiFenAddValue(client, -JiFenAdd, "精灵神迹积分注入", true, true); GameManager.ClientMgr.ModifyShenJiPointValue(client, 1, "精灵神迹积分注入", true, true); } else { GameManager.ClientMgr.ModifyShenJiJiFenValue(client, -CurJiFen, "精灵神迹积分注入", true, true); GameManager.ClientMgr.ModifyShenJiJiFenAddValue(client, CurJiFen, "精灵神迹积分注入", true, true); } client.sendCmd(nID, string.Format("{0}:{1}", result, roleID), false); return(true); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false); } return(false); }
public bool LoadShenJiPointConfigFile() { try { GeneralCachingXmlMgr.RemoveCachingXml(Global.GameResPath("Config/ShenJiDian.xml")); XElement xml = GeneralCachingXmlMgr.GetXElement(Global.GameResPath("Config/ShenJiDian.xml")); if (null == xml) { return(false); } List <ShenJiPointConfigData> tempShenJiPointConfig = new List <ShenJiPointConfigData>(); IEnumerable <XElement> xmlItems = xml.Elements(); foreach (XElement xmlItem in xmlItems) { ShenJiPointConfigData data = new ShenJiPointConfigData(); data.ShenJiPoint = (int)Global.GetSafeAttributeLong(xmlItem, "ShenJiDian"); data.NeedJiFen = (int)Global.GetSafeAttributeLong(xmlItem, "NeedShenJi"); string tempValue = Global.GetSafeAttributeStr(xmlItem, "NeedLevel"); string[] ValueFileds = tempValue.Split(new char[] { '|' }); if (ValueFileds.Length == 2) { int zhuanSheng = Global.SafeConvertToInt32(ValueFileds[0]); int level = Global.SafeConvertToInt32(ValueFileds[1]); data.NeedLevel = Global.GetUnionLevel2(zhuanSheng, level); } tempShenJiPointConfig.Add(data); } lock (this.ConfigMutex) { this.ShenJiPointConfig = tempShenJiPointConfig; } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现异常, {1}", "Config/ShenJiDian.xml", ex.Message), null, true); return(false); } return(true); }