/// <summary> /// 初始化管理器 /// </summary> public void init() { //缓存献花需要的钻石 try { dNeedGam = GameManager.systemParamsList.GetParamValueDoubleArrayByName("XianHuaCost"); } catch (System.Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic XianHuaCost", false); } //缓存婚戒最终属性系数 try { dRingmodulus = GameManager.systemParamsList.GetParamValueDoubleByName("GoodWillXiShu"); } catch (System.Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic GoodWillXiShu", false); } //对方婚戒属性倍率参数 try { dOtherRingmodulus = GameManager.systemParamsList.GetParamValueDoubleByName("BanLvXiShu"); } catch (System.Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic BanLvXiShu", false); } //加载婚戒数据 try { WeddingRingDic.LoadFromXMlFile("Config/WeddingRing.xml", "", "GoodsID"); } catch (System.Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic WeddingRing.xml", false); } //加载玫瑰花数据 try { SystemXmlItems RoseXmlItems = new SystemXmlItems(); RoseXmlItems.LoadFromXMlFile("Config/GiveRose.xml", "", "GoodsID"); foreach (KeyValuePair <int, SystemXmlItem> item in RoseXmlItems.SystemXmlItemDict) { MarriageRoseData rosedata = new MarriageRoseData(); rosedata.nBaseAddGoodWill = item.Value.GetIntValue("GoodWill"); string[] strfiled = item.Value.GetStringValue("MultiplyingPower").Split('|'); int nAddRate = 0; for (int i = 0; i < strfiled.Length; ++i) { string[] strfiled2 = strfiled[i].Split(','); //预先计算一下几率 nAddRate += (int)(Convert.ToDouble(strfiled2[1]) * 100.0d); rosedata.modulusList.Add(Convert.ToInt32(strfiled2[0])); rosedata.rateList.Add(nAddRate); } RoseDataDic.Add(Convert.ToInt32(item.Value.GetIntValue("GoodsID")), rosedata); } } catch (System.Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic GiveRose.xml", false); } //加载奉献数据 try { SystemXmlItems XmlItems = new SystemXmlItems(); XmlItems.LoadFromXMlFile("Config/GoodWill.xml", "", "Type"); sbyte tmpStar = 0; int nAddExp = 0; //预先把1阶0星加进去 GoodwillAllExpList.Add(0); foreach (var item in XmlItems.SystemXmlItemDict) { tmpStar = 0; foreach (var xmlnode in item.Value.XMLNode.Descendants()) { nAddExp += Convert.ToInt32(xmlnode.Attribute("NeedGoodWill").Value); GoodwillAllExpList.Add(nAddExp); tmpStar++; } } //动态设置一下最大阶级 byMaxGoodwillLv = (sbyte)((GoodwillAllExpList.Count - 1) / tmpStar); //动态设置一下最大星级 byMaxGoodwillStar = tmpStar; } catch (System.Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic GoodWill.xml", false); } //初始化协议列表 TCPCmdDispatcher.getInstance().registerProcessorEx((int)TCPGameServerCmds.CMD_SPR_MARRY_ROSE, 1, 1, getInstance()); TCPCmdDispatcher.getInstance().registerProcessorEx((int)TCPGameServerCmds.CMD_SPR_MARRY_RING, 1, 1, getInstance()); TCPCmdDispatcher.getInstance().registerProcessorEx((int)TCPGameServerCmds.CMD_SPR_MARRY_MESSAGE, 1, 1, getInstance()); //初始化消息监听器 //GlobalEventSource.getInstance().registerListener((int)EventTypes.PlayerInitGame, getInstance()); //玩家登陆事件 }
public MarryOtherResult GiveRose(GameClient client, int nGoodsDBId) { MarryOtherResult result; if (client.ClientData.MyMarriageData.byMarrytype == -1) { result = MarryOtherResult.NotMarriaged; } else if (client.ClientData.MyMarriageData.byGoodwilllevel == this.byMaxGoodwillLv && client.ClientData.MyMarriageData.byGoodwillstar == this.byMaxGoodwillStar) { result = MarryOtherResult.MaxLimit; } else { GoodsData goodsData = Global.GetGoodsByID(client, nGoodsDBId); if (null == goodsData) { result = MarryOtherResult.NotFindItem; } else { lock (this.RoseDataDic) { MarriageRoseData rosedata = null; if (!this.RoseDataDic.TryGetValue(goodsData.GoodsID, out rosedata)) { return(MarryOtherResult.ItemNotRose); } int ngamcost; if (client.ClientData.MyMarriageData.nGivenrose < this.dNeedGam.Length) { ngamcost = Convert.ToInt32(this.dNeedGam[client.ClientData.MyMarriageData.nGivenrose]); } else { ngamcost = Convert.ToInt32(this.dNeedGam[this.dNeedGam.Length - 1]); } if (ngamcost != 0 && !GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, ngamcost, "结婚献花", true, true, false, DaiBiSySType.None)) { return(MarryOtherResult.NeedGam); } if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsData, 1, false, false)) { return(MarryOtherResult.NeedRose); } client.ClientData.MyMarriageData.nGivenrose++; int nRank = Global.GetRandomNumber(0, 100); int nModulus = 1; for (int i = 0; i < rosedata.rateList.Count; i++) { if (nRank < rosedata.rateList[i]) { nModulus = rosedata.modulusList[i]; break; } } this.UpdateMarriageGoodWill(client, rosedata.nBaseAddGoodWill * nModulus); if (nModulus != 1) { return(MarryOtherResult.CirEffect); } } result = MarryOtherResult.Success; } } return(result); }
/// <summary> /// 送花 /// </summary> public MarryOtherResult GiveRose(GameClient client, int nGoodsDBId) { //看看是不是情侣 if (client.ClientData.MyMarriageData.byMarrytype == -1) { return(MarryOtherResult.NotMarriaged); } //到达上限不加 if (client.ClientData.MyMarriageData.byGoodwilllevel == byMaxGoodwillLv && client.ClientData.MyMarriageData.byGoodwillstar == byMaxGoodwillStar) { return(MarryOtherResult.MaxLimit); } //看看今日是否还有献花次数 现在版本没有次数限制 可以一直捐献 //if (client.ClientData.MyMarriageData.nGivenrose >= 15) //return; //在包裹里找到这个物品 GoodsData goodsData = Global.GetGoodsByID(client, nGoodsDBId); if (null == goodsData) { return(MarryOtherResult.NotFindItem); } lock (RoseDataDic) { //看看这个物品是不是属于花类 MarriageRoseData rosedata = null; if (!RoseDataDic.TryGetValue(goodsData.GoodsID, out rosedata)) { return(MarryOtherResult.ItemNotRose); } //检查一下钻石 int ngamcost = 0; //如果次数不够最高按照表来 if (client.ClientData.MyMarriageData.nGivenrose < dNeedGam.Length) { ngamcost = Convert.ToInt32(dNeedGam[client.ClientData.MyMarriageData.nGivenrose]); } else { //如果次数超过表上限则按最高的花费钻石 ngamcost = Convert.ToInt32(dNeedGam[dNeedGam.Length - 1]); } if (ngamcost != 0 && !GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, ngamcost, "结婚献花")) { return(MarryOtherResult.NeedGam); } //扣除物品 if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsData, 1, false)) { return(MarryOtherResult.NeedRose); } //更新献花次数 client.ClientData.MyMarriageData.nGivenrose++; //根据几率来选择增加奉献值的倍率 int nRank = Global.GetRandomNumber(0, 100); int nModulus = 1; for (int i = 0; i < rosedata.rateList.Count; ++i) { if (nRank < rosedata.rateList[i]) { nModulus = rosedata.modulusList[i]; break; } } //增加奉献值=基础奉献值*倍率系数 UpdateMarriageGoodWill(client, (rosedata.nBaseAddGoodWill * nModulus)); //出现暴击效果返回给客户端 if (nModulus != 1) { return(MarryOtherResult.CirEffect); } } return(MarryOtherResult.Success); }
public void init() { try { this.dNeedGam = GameManager.systemParamsList.GetParamValueDoubleArrayByName("XianHuaCost", ','); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic XianHuaCost", false, false); } try { this.dRingmodulus = GameManager.systemParamsList.GetParamValueDoubleByName("GoodWillXiShu", 0.0); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic GoodWillXiShu", false, false); } try { this.dOtherRingmodulus = GameManager.systemParamsList.GetParamValueDoubleByName("BanLvXiShu", 0.0); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic BanLvXiShu", false, false); } try { this.WeddingRingDic.LoadFromXMlFile("Config/WeddingRing.xml", "", "GoodsID", 0); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic WeddingRing.xml", false, false); } try { SystemXmlItems RoseXmlItems = new SystemXmlItems(); RoseXmlItems.LoadFromXMlFile("Config/GiveRose.xml", "", "GoodsID", 0); foreach (KeyValuePair <int, SystemXmlItem> item in RoseXmlItems.SystemXmlItemDict) { MarriageRoseData rosedata = new MarriageRoseData(); rosedata.nBaseAddGoodWill = item.Value.GetIntValue("GoodWill", -1); string[] strfiled = item.Value.GetStringValue("MultiplyingPower").Split(new char[] { '|' }); int nAddRate = 0; for (int i = 0; i < strfiled.Length; i++) { string[] strfiled2 = strfiled[i].Split(new char[] { ',' }); nAddRate += (int)(Convert.ToDouble(strfiled2[1]) * 100.0); rosedata.modulusList.Add(Convert.ToInt32(strfiled2[0])); rosedata.rateList.Add(nAddRate); } this.RoseDataDic.Add(Convert.ToInt32(item.Value.GetIntValue("GoodsID", -1)), rosedata); } } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic GiveRose.xml", false, false); } try { SystemXmlItems XmlItems = new SystemXmlItems(); XmlItems.LoadFromXMlFile("Config/GoodWill.xml", "", "Type", 0); sbyte tmpStar = 0; int nAddExp = 0; this.GoodwillAllExpList.Add(0); foreach (KeyValuePair <int, SystemXmlItem> item in XmlItems.SystemXmlItemDict) { tmpStar = 0; foreach (XElement xmlnode in item.Value.XMLNode.Descendants()) { nAddExp += Convert.ToInt32(xmlnode.Attribute("NeedGoodWill").Value); this.GoodwillAllExpList.Add(nAddExp); tmpStar += 1; } } this.byMaxGoodwillLv = (sbyte)((this.GoodwillAllExpList.Count - 1) / (int)tmpStar); this.byMaxGoodwillStar = tmpStar; } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic GoodWill.xml", false, false); } TCPCmdDispatcher.getInstance().registerProcessorEx(871, 1, 1, MarriageOtherLogic.getInstance(), TCPCmdFlags.IsStringArrayParams); TCPCmdDispatcher.getInstance().registerProcessorEx(872, 1, 1, MarriageOtherLogic.getInstance(), TCPCmdFlags.IsStringArrayParams); TCPCmdDispatcher.getInstance().registerProcessorEx(873, 1, 1, MarriageOtherLogic.getInstance(), TCPCmdFlags.IsStringArrayParams); }