/// <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)); } } }
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 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 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; } } } }