public static void LoadUnionPalaceRateInfo() { string fileName = Global.GameResPath("Config/ShenDianScale.xml"); XElement xml = CheckHelper.LoadXml(fileName); if (null == xml) { return; } try { _unionPalaceRateList.Clear(); IEnumerable <XElement> xmlItems = xml.Elements(); foreach (var xmlItem in xmlItems) { if (xmlItem == null) { continue; } UnionPalaceRateInfo config = new UnionPalaceRateInfo(); config.StatueLevel = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "Level", "0")); string addString = Convert.ToString(Global.GetDefAttributeStr(xmlItem, "Scale", "")); if (addString.Length > 0) { string[] addArr = addString.Split('|'); foreach (string str in addArr) { string[] oneArr = str.Split(','); int rate = (int)(float.Parse(oneArr[0]) * 100); config.RateList.Add(rate); List <int> valueList = new List <int>(); for (int i = 1; i < oneArr.Length; i++) { valueList.Add(int.Parse(oneArr[i])); } config.AddNumList.Add(rate, valueList); } _unionPalaceRateList.Add(config.StatueLevel, config); } //if } //foreach } catch (Exception ex) { LogManager.WriteLog(LogTypes.Fatal, string.Format("加载[{0}]时出错!!!", fileName)); } }
public static UnionPalaceData UnionPalaceUp(GameClient client) { UnionPalaceData result; lock (client.ClientData.LockUnionPalace) { UnionPalaceData myUPData = UnionPalaceManager.UnionPalaceGetData(client, false); if (myUPData.ResultType < 0) { result = myUPData; } else if (myUPData.ResultType == 3 || myUPData.ResultType == -4) { myUPData.ResultType = -4; result = myUPData; } else if (!UnionPalaceManager.IsGongNengOpened(client)) { myUPData.ResultType = -1; result = myUPData; } else { UnionPalaceBasicInfo basicInfo = UnionPalaceManager.GetUPBasicInfoByID(myUPData.StatueID); if (basicInfo.UnionLevel < 0) { myUPData.ResultType = -4; result = myUPData; } else { int bhLevel = Global.GetBangHuiLevel(client); if (basicInfo.UnionLevel > bhLevel) { myUPData.ResultType = -8; result = myUPData; } else if (bhLevel < myUPData.StatueLevel) { myUPData.ResultType = -7; result = myUPData; } else { int zhanGongNeed = UnionPalaceManager.GetUnionPalaceZG(client, 0); if (!GameManager.ClientMgr.SubUserBangGong(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, zhanGongNeed)) { myUPData.ResultType = -3; result = myUPData; } else { UnionPalaceRateInfo rateInfo = UnionPalaceManager.GetUPRateInfoByID(basicInfo.StatueLevel); int[] addNums = null; int rate = 0; int r = Global.GetRandomNumber(0, 100); for (int i = 0; i < rateInfo.RateList.Count; i++) { rate += rateInfo.RateList[i]; if (r <= rate) { addNums = rateInfo.AddNumList[rateInfo.RateList[i]].ToArray(); myUPData.BurstType = i; break; } } List <int> logList = new List <int>(); logList.Add(myUPData.StatueID); logList.Add(myUPData.LifeAdd); logList.Add(myUPData.AttackAdd); logList.Add(myUPData.DefenseAdd); logList.Add(myUPData.AttackInjureAdd); myUPData.LifeAdd += addNums[0] * UnionPalaceManager._gmRate; myUPData.LifeAdd = ((myUPData.LifeAdd > basicInfo.LifeMax) ? basicInfo.LifeMax : myUPData.LifeAdd); myUPData.AttackAdd += addNums[1] * UnionPalaceManager._gmRate; myUPData.AttackAdd = ((myUPData.AttackAdd > basicInfo.AttackMax) ? basicInfo.AttackMax : myUPData.AttackAdd); myUPData.DefenseAdd += addNums[2] * UnionPalaceManager._gmRate; myUPData.DefenseAdd = ((myUPData.DefenseAdd > basicInfo.DefenseMax) ? basicInfo.DefenseMax : myUPData.DefenseAdd); myUPData.AttackInjureAdd += addNums[3] * UnionPalaceManager._gmRate; myUPData.AttackInjureAdd = ((myUPData.AttackInjureAdd > basicInfo.AttackInjureMax) ? basicInfo.AttackInjureMax : myUPData.AttackInjureAdd); if (myUPData.LifeAdd < basicInfo.LifeMax || myUPData.DefenseAdd < basicInfo.DefenseMax || myUPData.AttackAdd < basicInfo.AttackMax || myUPData.AttackInjureAdd < basicInfo.AttackInjureMax) { myUPData.ResultType = 1; } else { myUPData.StatueID++; basicInfo = UnionPalaceManager.GetUPBasicInfoByID(myUPData.StatueID); myUPData.StatueType = basicInfo.StatueType; myUPData.StatueLevel = basicInfo.StatueLevel; myUPData.LifeAdd = 0; myUPData.AttackAdd = 0; myUPData.DefenseAdd = 0; myUPData.AttackInjureAdd = 0; myUPData.ResultType = 2; if (myUPData.StatueID > UnionPalaceManager._unionPalaceBasicList.Count || basicInfo.UnionLevel < 0) { myUPData.ResultType = 3; } else if (bhLevel < basicInfo.UnionLevel) { myUPData.ResultType = 5; } else if (bhLevel < myUPData.StatueLevel) { myUPData.ResultType = 4; } } int today = Global.GetOffsetDayNow(); int upCount = UnionPalaceManager.GetUpCount(client, today); myUPData.ZhanGongNeed = UnionPalaceManager.GetUnionPalaceZG(client, upCount + 1); UnionPalaceManager.ModifyUpCount(client, upCount + 1); UnionPalaceManager.ModifyUnionPalaceData(client, myUPData); client.ClientData.MyUnionPalaceData = myUPData; UnionPalaceManager.SetUnionPalaceProps(client, myUPData); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7); myUPData.ZhanGongLeft = client.ClientData.BangGong; logList.Add(myUPData.StatueID); logList.Add(myUPData.LifeAdd); logList.Add(myUPData.AttackAdd); logList.Add(myUPData.DefenseAdd); logList.Add(myUPData.AttackInjureAdd); logList.Add(upCount); EventLogManager.AddUnionPalaceEvent(client, LogRecordType.UnionPalace, new object[] { logList.ToArray() }); result = myUPData; } } } } } return(result); }
public static UnionPalaceData UnionPalaceUp(GameClient client) { lock (client.ClientData.LockUnionPalace) { UnionPalaceData myUPData = UnionPalaceGetData(client); if (myUPData.ResultType < (int)EUnionPalaceState.Default) { return(myUPData); } if (myUPData.ResultType == (int)EUnionPalaceState.End || myUPData.ResultType == (int)EUnionPalaceState.EOver) { myUPData.ResultType = (int)EUnionPalaceState.EOver; return(myUPData); } UnionPalaceBasicInfo basicInfo = GetUPBasicInfoByID(myUPData.StatueID); if (basicInfo.UnionLevel < 0) { myUPData.ResultType = (int)EUnionPalaceState.EOver; return(myUPData); } int bhLevel = Global.GetBangHuiLevel(client); if (basicInfo.UnionLevel > bhLevel) { myUPData.ResultType = (int)EUnionPalaceState.EUnionNeedUp; return(myUPData); } if (bhLevel < myUPData.StatueLevel) { myUPData.ResultType = (int)EUnionPalaceState.EPalaceMore; return(myUPData); } int zhanGongNeed = GetUnionPalaceZG(client); if (!GameManager.ClientMgr.SubUserBangGong(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, zhanGongNeed)) { myUPData.ResultType = (int)EUnionPalaceState.EnoZhanGong; return(myUPData); } //几率 UnionPalaceRateInfo rateInfo = GetUPRateInfoByID(basicInfo.StatueLevel); int[] addNums = null; int rate = 0; int r = Global.GetRandomNumber(0, 100); for (int i = 0; i < rateInfo.RateList.Count; i++) { rate += rateInfo.RateList[i]; if (r <= rate) { addNums = rateInfo.AddNumList[rateInfo.RateList[i]].ToArray(); myUPData.BurstType = i;//暴击 break; } } List <int> logList = new List <int>(); logList.Add(myUPData.StatueID); logList.Add(myUPData.LifeAdd); logList.Add(myUPData.AttackAdd); logList.Add(myUPData.DefenseAdd); logList.Add(myUPData.AttackInjureAdd); //加成 myUPData.LifeAdd += addNums[0] * _gmRate; myUPData.LifeAdd = myUPData.LifeAdd > basicInfo.LifeMax ? basicInfo.LifeMax : myUPData.LifeAdd; myUPData.AttackAdd += addNums[1] * _gmRate; myUPData.AttackAdd = myUPData.AttackAdd > basicInfo.AttackMax ? basicInfo.AttackMax : myUPData.AttackAdd; myUPData.DefenseAdd += addNums[2] * _gmRate; myUPData.DefenseAdd = myUPData.DefenseAdd > basicInfo.DefenseMax ? basicInfo.DefenseMax : myUPData.DefenseAdd; myUPData.AttackInjureAdd += addNums[3] * _gmRate; myUPData.AttackInjureAdd = myUPData.AttackInjureAdd > basicInfo.AttackInjureMax ? basicInfo.AttackInjureMax : myUPData.AttackInjureAdd; if (myUPData.LifeAdd < basicInfo.LifeMax || myUPData.DefenseAdd < basicInfo.DefenseMax || myUPData.AttackAdd < basicInfo.AttackMax || myUPData.AttackInjureAdd < basicInfo.AttackInjureMax) { myUPData.ResultType = (int)EUnionPalaceState.Success; } else { myUPData.StatueID += 1; basicInfo = GetUPBasicInfoByID(myUPData.StatueID); myUPData.StatueType = basicInfo.StatueType; myUPData.StatueLevel = basicInfo.StatueLevel; myUPData.LifeAdd = 0; myUPData.AttackAdd = 0; myUPData.DefenseAdd = 0; myUPData.AttackInjureAdd = 0; myUPData.ResultType = (int)EUnionPalaceState.Next; if (myUPData.StatueID > _unionPalaceBasicList.Count || basicInfo.UnionLevel < 0) { myUPData.ResultType = (int)EUnionPalaceState.End; } else if (bhLevel < basicInfo.UnionLevel) { myUPData.ResultType = (int)EUnionPalaceState.UnionNeedUp; } else if (bhLevel < myUPData.StatueLevel) { myUPData.ResultType = (int)EUnionPalaceState.PalaceMore; } } int today = Global.GetOffsetDayNow(); int upCount = GetUpCount(client, today); myUPData.ZhanGongNeed = GetUnionPalaceZG(client, upCount + 1); ModifyUpCount(client, upCount + 1); ModifyUnionPalaceData(client, myUPData); client.ClientData.MyUnionPalaceData = myUPData; SetUnionPalaceProps(client, myUPData); //通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); myUPData.ZhanGongLeft = client.ClientData.BangGong; logList.Add(myUPData.StatueID); logList.Add(myUPData.LifeAdd); logList.Add(myUPData.AttackAdd); logList.Add(myUPData.DefenseAdd); logList.Add(myUPData.AttackInjureAdd); logList.Add(upCount); EventLogManager.AddUnionPalaceEvent(client, LogRecordType.UnionPalace, logList.ToArray()); //LogManager.WriteLog(LogTypes.Error, string.Format("-------------------------------------------union palace end {0}", myUPData.StatueID)); return(myUPData); } }