/// <summary> /// 警告处理 /// </summary> /// <param name="roleName">角色name</param> /// <param name="warnType">警告类型</param> public static void WarnProcess(string userID, int warnType) { WarnInfo info = GetWarnInfo(warnType); if (info == null) { return; } TMSKSocket socket = GameManager.OnlineUserSession.FindSocketByUserID(userID); if (socket == null) { return; } GameClient client = GameManager.ClientMgr.FindClient(socket); if (null != client) { client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WARN_INFO, info); if (info.Operate != (int)WarnOperateType.Hand) { AddTaskToHashSet(client, info.TimeSec); } } /*/根据ID查找敌人 * int roleID = RoleName2IDs.FindRoleIDByName(roleName, true); * if (roleID <= 0) return; * * GameClient client = GameManager.ClientMgr.FindClient(roleID);*/ }
public static void initWarnInfo() { string fileName = Global.IsolateResPath("Config/JingGao.xml"); XElement xml = CheckHelper.LoadXml(fileName, true); if (null != xml) { try { WarnManager._warnInfoList.Clear(); IEnumerable <XElement> xmlItems = xml.Elements(); foreach (XElement xmlItem in xmlItems) { if (xmlItem != null) { WarnInfo config = new WarnInfo(); config.ID = Convert.ToInt32(Global.GetSafeAttributeLong(xmlItem, "ID")); config.Desc = Global.GetSafeAttributeStr(xmlItem, "Description"); config.TimeSec = Convert.ToInt32(Global.GetSafeAttributeLong(xmlItem, "Time")); config.Operate = Convert.ToInt32(Global.GetSafeAttributeLong(xmlItem, "Operate")); WarnManager._warnInfoList.Add(config.Operate, config); } } } catch (Exception) { LogManager.WriteLog(LogTypes.Fatal, string.Format("加载[{0}]时出错!!!", fileName), null, true); } } }
public static void WarnProcess(string userID, int warnType) { WarnInfo info = WarnManager.GetWarnInfo(warnType); if (info != null) { TMSKSocket socket = GameManager.OnlineUserSession.FindSocketByUserID(userID); if (socket != null) { GameClient client = GameManager.ClientMgr.FindClient(socket); if (null != client) { client.sendCmd <WarnInfo>(1004, info, false); if (info.Operate != 1) { WarnManager.AddTaskToHashSet(client, info.TimeSec); } } } } }