/// <summary> /// 开启庆功宴 /// </summary> private void OpenQingGongYan() { QingGongYanOpenFlag = true; QingGongYanInfo InfoData = GetInfoData(); if (null == InfoData) { return; } GameMap gameMap = GameManager.MapMgr.DictMaps[InfoData.MapCode]; // 策划要求x, y改成直接传值 NPC npc = NPCGeneralManager.GetNPCFromConfig(InfoData.MapCode, InfoData.NpcID, InfoData.X, InfoData.Y, InfoData.Direction); if (null != npc) { if (NPCGeneralManager.AddNpcToMap(npc)) { QingGongYanNpc = npc; //播放用户行为消息 string guildName = GameManager.GameConfigMgr.GetGameConfigItemStr(GameConfigNames.QGYGuildName, ""); string broadCastMsg = StringUtil.substitute(Global.GetLang("为庆祝{0}战盟在罗兰城战中取得胜利,慷慨的罗兰城主正在勇者大陆摆开宴席,恭候各位光临!"), guildName); Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.SysHintAndChatBox); } else { LogManager.WriteLog(LogTypes.Error, string.Format("OpenQingGongYan, AddNpcToMap Faild !InfoData.MapCode={0}, InfoData.NpcID={1}", InfoData.MapCode, InfoData.NpcID)); } } }
/// <summary> /// 关闭庆功宴 /// </summary> private void CloseQingGongYan() { // 销毁怪物 if (null != QingGongYanNpc) { NPCGeneralManager.RemoveMapNpc(QingGongYanNpc.MapCode, QingGongYanNpc.NpcID); QingGongYanNpc = null; } QingGongYanOpenFlag = false; // log it... // 档次没有配置 QingGongYanInfo InfoData = GetInfoData(); if (null == InfoData) { return; } if (InfoData.ZuanShiCoe <= 0) { return; } int JoinMoney = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYJoinMoney, 0); int ZuanShiAward = JoinMoney / InfoData.ZuanShiCoe; int DBRoleID = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYRoleID, 0); if (DBRoleID <= 0) { return; } //string sContent = "您在2015年02月02日 20:00举办的宴会已成功结束,共获得收益200钻石。"; string sContent = string.Format(Global.GetLang("您在{0:0000}年{1:00}月{2:00}日 {3:00}点{4:00}分举办的宴会已成功结束,共获得收益{5}钻石。"), TimeUtil.NowDateTime().Year, TimeUtil.NowDateTime().Month, TimeUtil.NowDateTime().Day, DateTime.Parse(InfoData.BeginTime).Hour, DateTime.Parse(InfoData.BeginTime).Minute, ZuanShiAward); Global.UseMailGivePlayerAward3(DBRoleID, null, Global.GetLang("庆功宴"), sContent, ZuanShiAward); // 清空记录 Global.UpdateDBGameConfigg(GameConfigNames.QGYRoleID, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYRoleID, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYGuildName, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGuildName, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYStartDay, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYStartDay, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYGrade, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGrade, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinCount, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinCount, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinMoney, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinMoney, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYJuBanMoney, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJuBanMoney, ""); //播放用户行为消息 string broadCastMsg = StringUtil.substitute(Global.GetLang("本次罗兰宴会已圆满结束,愿大家满载而归!")); Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.SysHintAndChatBox); }
public void MarryPartyPeriodicUpdate(long ticks) { if (ticks >= this.NextUpdateTime) { this.NextUpdateTime = ticks + 10000L; bool showNPC = this.m_MarryPartyDataCache.HasPartyStarted(ticks); if (showNPC != this.MarryPartyNPCShow) { this.MarryPartyNPCShow = showNPC; if (showNPC) { GameMap gameMap = GameManager.MapMgr.DictMaps[this.MarryPartyNPCConfig.MapCode]; NPC npc = NPCGeneralManager.GetNPCFromConfig(this.MarryPartyNPCConfig.MapCode, this.MarryPartyNPCConfig.NpcID, this.MarryPartyNPCConfig.NpcX, this.MarryPartyNPCConfig.NpcY, this.MarryPartyNPCConfig.NpcDir); if (null != npc) { if (NPCGeneralManager.AddNpcToMap(npc)) { this.MarryPartyNpc = npc; } else { LogManager.WriteLog(LogTypes.Error, string.Format("add marry party npc failure, MapCode={0}, NpcID={1}", this.MarryPartyNPCConfig.MapCode, this.MarryPartyNPCConfig.NpcID), null, true); } } } else if (null != this.MarryPartyNpc) { NPCGeneralManager.RemoveMapNpc(this.MarryPartyNPCConfig.MapCode, this.MarryPartyNPCConfig.NpcID); this.MarryPartyNpc = null; } } } }
private void OpenQingGongYan() { this.QingGongYanOpenFlag = true; QingGongYanInfo InfoData = this.GetInfoData(); if (null != InfoData) { GameMap gameMap = GameManager.MapMgr.DictMaps[InfoData.MapCode]; NPC npc = NPCGeneralManager.GetNPCFromConfig(InfoData.MapCode, InfoData.NpcID, InfoData.X, InfoData.Y, InfoData.Direction); if (null != npc) { if (NPCGeneralManager.AddNpcToMap(npc)) { GameManager.ClientMgr.BroadcastServerCmd(733, "1", false); this.QingGongYanNpc = npc; string guildName = GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_guildname", ""); string broadCastMsg = StringUtil.substitute(GLang.GetLang(524, new object[0]), new object[] { guildName }); Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.SysHintAndChatBox, 0, 0, 100, 100); } else { LogManager.WriteLog(LogTypes.Error, string.Format("OpenQingGongYan, AddNpcToMap Faild !InfoData.MapCode={0}, InfoData.NpcID={1}", InfoData.MapCode, InfoData.NpcID), null, true); } } } }
public void AddNpcToMap(int npcID, int mapCode, int toX, int toY) { NPC npc = NPCGeneralManager.GetNPCFromConfig(mapCode, npcID, toX, toY, 0); if (null != npc) { NPCGeneralManager.AddNpcToMap(npc); } }
public void AddNPCForClient(GameClient client, int npcID, int toX, int toY) { NPC npc = NPCGeneralManager.GetNPCFromConfig(client.ClientData.MapCode, npcID, toX, toY, 0); if (null != npc) { GameManager.ClientMgr.NotifyMySelfNewNPC(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, npc); } }
public static bool ReloadMapNPCRoles(int mapCode) { string fileName = string.Format("Map/{0}/npcs.xml", mapCode); GeneralCachingXmlMgr.Reload(Global.ResPath(fileName)); GameManager.SystemNPCsMgr.ReloadLoadFromXMlFile(); GameMap gameMap = GameManager.MapMgr.DictMaps[mapCode]; return(NPCGeneralManager.LoadMapNPCRoles(mapCode, gameMap)); }
public void RestorePKingNpc(int pkKingRoleID) { NPC npc = NPCGeneralManager.FindNPC(GameManager.MainMapCode, FakeRoleNpcId.PkKing); if (null != npc) { npc.ShowNpc = true; GameManager.ClientMgr.NotifyMySelfNewNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, npc); FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.DiaoXiang, false); } }
private void CloseQingGongYan() { if (null != this.QingGongYanNpc) { NPCGeneralManager.RemoveMapNpc(this.QingGongYanNpc.MapCode, this.QingGongYanNpc.NpcID); this.QingGongYanNpc = null; GameManager.ClientMgr.BroadcastServerCmd(733, "0", false); } this.QingGongYanOpenFlag = false; QingGongYanInfo InfoData = this.GetInfoData(); if (null != InfoData) { if (InfoData.ZuanShiCoe > 0) { int JoinMoney = GameManager.GameConfigMgr.GetGameConfigItemInt("qinggongyan_joinmoney", 0); int ZuanShiAward = JoinMoney / InfoData.ZuanShiCoe; int DBRoleID = GameManager.GameConfigMgr.GetGameConfigItemInt("qinggongyan_roleid", 0); if (DBRoleID > 0) { string sContent = string.Format(GLang.GetLang(525, new object[0]), new object[] { TimeUtil.NowDateTime().Year, TimeUtil.NowDateTime().Month, TimeUtil.NowDateTime().Day, DateTime.Parse(InfoData.BeginTime).Hour, DateTime.Parse(InfoData.BeginTime).Minute, ZuanShiAward }); Global.UseMailGivePlayerAward3(DBRoleID, null, GLang.GetLang(526, new object[0]), sContent, ZuanShiAward, 0, 0); Global.UpdateDBGameConfigg("qinggongyan_roleid", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_roleid", ""); Global.UpdateDBGameConfigg("qinggongyan_guildname", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_guildname", ""); Global.UpdateDBGameConfigg("qinggongyan_startday", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_startday", ""); Global.UpdateDBGameConfigg("qinggongyan_grade", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_grade", ""); Global.UpdateDBGameConfigg("qinggongyan_joincount", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joincount", ""); Global.UpdateDBGameConfigg("qinggongyan_joinmoney", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joinmoney", ""); Global.UpdateDBGameConfigg("qinggongyan_jubanmoney", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_jubanmoney", ""); string broadCastMsg = StringUtil.substitute(GLang.GetLang(527, new object[0]), new object[0]); Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.SysHintAndChatBox, 0, 0, 100, 100); } } } }
public static void ProcessAddMonster(Monster monster) { try { DateTime now = TimeUtil.NowDateTime(); if ((now - MoYuLongXue.MoYuRunTimeData.LastBirthTimePoint).TotalMinutes > 1.0) { Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.HintMsg, string.Format(GLang.GetLang(4004, new object[0]), monster.MonsterInfo.VSName), true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.HintAndBox, 0, 0, 100, 100); MoYuLongXue.MoYuRunTimeData.LastBirthTimePoint = now; } NPC npc = null; int mapCode = 0; int leftCount = 0; lock (MoYuLongXue.MoYuRunTimeData.Mutex) { MoYuMonsterInfo moYuInfo; if (!MoYuLongXue.MoYuRunTimeData.MonsterXmlDict.TryGetValue(monster.MonsterInfo.ExtensionID, out moYuInfo)) { return; } mapCode = moYuInfo.MapCode; MoYuLongXue.MoYuRunTimeData.BossAttackLogDict[monster.RoleID] = new BossAttackLog { InjureSum = 0L, BHInjure = new Dictionary <long, BHAttackLog>(), BHAttackRank = new List <BHAttackLog>() }; leftCount = MoYuLongXue.MoYuRunTimeData.BossAttackLogDict.Count; npc = NPCGeneralManager.FindNPC(moYuInfo.MapCode, moYuInfo.NpcID); } if (null != npc) { npc.ShowNpc = false; GameManager.ClientMgr.NotifyMySelfDelNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, npc); } List <GameClient> clientList = GameManager.ClientMgr.GetMapGameClients(mapCode); foreach (GameClient client in clientList) { client.sendCmd <int>(1907, leftCount, false); } MoYuLongXue.NotifyBossLogBy9Grid(monster); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, string.Format("MoYuLongXue :: 处理场景刷新怪物异常。", new object[0]), ex, true); } }
public static bool LoadMapNPCRoles(int mapCode, GameMap gameMap) { string fileName = string.Format("Map/{0}/npcs.xml", mapCode); XElement xml = GeneralCachingXmlMgr.GetXElement(Global.ResPath(fileName)); bool result; if (null == xml) { result = false; } else { IEnumerable <XElement> items = xml.Elements("NPCs").Elements <XElement>(); foreach (XElement item in items) { NPC myNpc = new NPC(); myNpc.NpcID = Convert.ToInt32((string)item.Attribute("Code")); myNpc.MapCode = mapCode; myNpc.CurrentPos = new Point((double)Convert.ToInt32((string)item.Attribute("X")), (double)Convert.ToInt32((string)item.Attribute("Y"))); if (item.Attribute("Dir") != null) { myNpc.CurrentDir = (Dircetions)Global.GetSafeAttributeLong(item, "Dir"); } else { myNpc.CurrentDir = Dircetions.DR_DOWN; } myNpc.RoleBufferData = NPCGeneralManager.GenerateNpcRoleBufferData(myNpc); if (null != myNpc.RoleBufferData) { NPCGeneralManager.AddNpcToMap(myNpc); int safeGridNum = 2; SystemXmlItem npcXmlItem; if (GameManager.SystemNPCsMgr.SystemXmlItemDict.TryGetValue(myNpc.NpcID, out npcXmlItem)) { safeGridNum = npcXmlItem.GetIntValue("IsSafe", -1); } if (safeGridNum > 0) { gameMap.SetPartialSafeRegion(myNpc.GridPoint, safeGridNum); } } } result = true; } return(result); }
public void ReplacePKKingNpc(int roleId) { RoleDataEx rd = this.KingRoleData; this.KingRoleData = null; if (rd == null || rd.RoleID != roleId) { rd = Global.sendToDB <RoleDataEx, KingRoleGetData>(13230, new KingRoleGetData { KingType = 1 }, 0); if (rd == null || rd.RoleID != roleId) { RoleDataEx dbRd = Global.sendToDB <RoleDataEx, string>(275, string.Format("{0}:{1}", -1, roleId), 0); if (dbRd == null || dbRd.RoleID <= 0) { return; } rd = dbRd; if (!Global.sendToDB <bool, KingRolePutData>(13231, new KingRolePutData { KingType = 1, RoleDataEx = rd }, 0)) { } } } if (rd != null && rd.RoleID > 0) { this.KingRoleData = rd; NPC npc = NPCGeneralManager.FindNPC(GameManager.MainMapCode, FakeRoleNpcId.PkKing); if (null != npc) { npc.ShowNpc = false; GameManager.ClientMgr.NotifyMySelfDelNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, npc); FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.DiaoXiang, false); FakeRoleManager.ProcessNewFakeRole(new SafeClientData { RoleData = rd }, npc.MapCode, FakeRoleTypes.DiaoXiang, 4, (int)npc.CurrentPos.X, (int)npc.CurrentPos.Y, FakeRoleNpcId.PkKing); } } }
public void MarryPartyPeriodicUpdate(long ticks) { // 10秒检测一次 if (ticks < NextUpdateTime) { return; } NextUpdateTime = ticks + 1000 * 10; bool showNPC = m_MarryPartyDataCache.HasPartyStarted(ticks); if (showNPC != MarryPartyNPCShow) { MarryPartyNPCShow = showNPC; if (showNPC == true) { GameMap gameMap = GameManager.MapMgr.DictMaps[MarryPartyNPCConfig.MapCode]; NPC npc = NPCGeneralManager.GetNPCFromConfig(MarryPartyNPCConfig.MapCode, MarryPartyNPCConfig.NpcID, MarryPartyNPCConfig.NpcX, MarryPartyNPCConfig.NpcY, MarryPartyNPCConfig.NpcDir); if (null != npc) { if (NPCGeneralManager.AddNpcToMap(npc)) { MarryPartyNpc = npc; } else { LogManager.WriteLog(LogTypes.Error, string.Format("add marry party npc failure, MapCode={0}, NpcID={1}", MarryPartyNPCConfig.MapCode, MarryPartyNPCConfig.NpcID)); } } } else { if (null != MarryPartyNpc) { NPCGeneralManager.RemoveMapNpc(MarryPartyNPCConfig.MapCode, MarryPartyNPCConfig.NpcID); MarryPartyNpc = null; } } } }
public static NPC GetNPCFromConfig(int mapCode, int npcID, int toX, int toY, int dir) { SystemXmlItem systemNPCItem = null; NPC result; if (!GameManager.SystemNPCsMgr.SystemXmlItemDict.TryGetValue(npcID, out systemNPCItem)) { result = null; } else { GameMap gameMap = null; if (!GameManager.MapMgr.DictMaps.TryGetValue(mapCode, out gameMap)) { result = null; } else { NPC myNpc = new NPC(); myNpc.NpcID = npcID; myNpc.MapCode = mapCode; myNpc.CurrentPos = new Point((double)toX, (double)toY); myNpc.CurrentDir = (Dircetions)dir; myNpc.RoleBufferData = NPCGeneralManager.GenerateNpcRoleBufferData(myNpc); if (null == myNpc.RoleBufferData) { result = null; } else { result = myNpc; } } } return(result); }
/// <summary> /// 删除一个临时的地图NPC /// </summary> /// <param name="client"></param> /// <param name="gold"></param> public void RemoveMapNpc(int mapCode, int npcID) { NPCGeneralManager.RemoveMapNpc(mapCode, npcID); }
public static bool ProcessMonsterDie(Monster monster) { try { NPC npc = null; bool ret = true; int mapCode = 0; int leftCount = 0; lock (MoYuLongXue.MoYuRunTimeData.Mutex) { BossAttackLog attackLog; MoYuMonsterInfo monsterInfo; if (!MoYuLongXue.MoYuRunTimeData.BossAttackLogDict.TryGetValue(monster.RoleID, out attackLog)) { ret = false; } else if (!MoYuLongXue.MoYuRunTimeData.MonsterXmlDict.TryGetValue(monster.MonsterInfo.ExtensionID, out monsterInfo)) { ret = false; } else { mapCode = monsterInfo.MapCode; List <BHAttackLog> bhAttackLogList = attackLog.BHAttackRank; int countLimit = Global.GMin(bhAttackLogList.Count, 5); for (int i = 0; i < countLimit; i++) { foreach (KeyValuePair <int, long> role in bhAttackLogList[i].RoleInjure) { GameClient client = GameManager.ClientMgr.FindClient(role.Key); if (null != client) { if (client.ClientData.MapCode == monsterInfo.MapCode) { if (role.Value >= (long)monsterInfo.HurtMin) { GameManager.ClientMgr.ModifyChengJiuPointsValue(client, monsterInfo.Chengjiu, "魔域龙穴boss奖励", true, true); GameManager.ClientMgr.ModifyShengWangValue(client, monsterInfo.Shengwang, "魔域龙穴boss奖励", true, true); } } } } } npc = NPCGeneralManager.FindNPC(monsterInfo.MapCode, monsterInfo.NpcID); } MoYuLongXue.MoYuRunTimeData.BossAttackLogDict.Remove(monster.RoleID); leftCount = MoYuLongXue.MoYuRunTimeData.BossAttackLogDict.Count; } List <GameClient> clientList = GameManager.ClientMgr.GetMapGameClients(mapCode); foreach (GameClient client in clientList) { client.sendCmd <int>(1907, leftCount, false); } if (null != npc) { npc.ShowNpc = true; GameManager.ClientMgr.NotifyMySelfNewNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, npc); } return(ret); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, string.Format("MoYuLongXue :: 处理boss被击杀异常。", new object[0]), ex, true); } return(false); }