public override bool Start() { bool result; try { LogProvider.Default = new LogProvider(new LogConfig { FilePath = "./log/fight/", UseConsole = true, UseFile = true }); this.m_running = true; Thread.CurrentThread.Priority = ThreadPriority.Normal; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException); CrossFightServer.log.Warn("正在初始化…………"); if (!Sql_DbObject.TryConnection()) { result = false; CrossFightServer.log.Error("数据库连接失败,请检查!"); return(result); } CrossFightServer.log.Info("数据库连接成功!"); if (!this.InitSocket(IPAddress.Parse(this.m_config.IP), this.m_config.Port)) { result = false; CrossFightServer.log.Error("初始化监听端口失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化监听端口成功!"); if (!MapMgr.Init()) { result = false; CrossFightServer.log.Error("初始化地图失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化地图成功!"); if (!ItemMgr.Init()) { result = false; CrossFightServer.log.Error("初始化物品失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化物品成功!"); if (!PropItemMgr.Init()) { result = false; CrossFightServer.log.Error("初始化道具失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化道具成功!"); if (!BallMgr.Init()) { result = false; CrossFightServer.log.Error("初始化炸弹失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化炸弹成功!"); if (!DropMgr.Init()) { result = false; CrossFightServer.log.Error("初始化掉落失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化掉落成功!"); if (!NPCInfoMgr.Init()) { result = false; CrossFightServer.log.Error("初始化npc失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化npc成功!"); if (!LanguageMgr.Load()) { result = false; CrossFightServer.log.Error("初始化语言包失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化语言包成功!"); if (!base.Start()) { result = false; CrossFightServer.log.Error("基础服务启动失败,请检查!"); return(result); } CrossFightServer.log.Info("基础服务启动成功!"); if (!ProxyRoomMgr.Setup()) { result = false; CrossFightServer.log.Error("启动房间管理服务失败,请检查!"); return(result); } ProxyRoomMgr.Start(); CrossFightServer.log.Info("启动房间管理服务成功!"); if (!GameMgr.Setup(0, 4)) { result = false; CrossFightServer.log.Error("启动游戏管理服务失败,请检查!"); return(result); } GameMgr.Start(); StartScriptComponents(); GameEventMgr.Notify(ScriptEvent.Loaded); CrossFightServer.log.Info("启动游戏管理服务成功!"); GC.Collect(GC.MaxGeneration); CrossFightServer.log.Warn("战斗服务器已启动!"); result = true; } catch (Exception e) { CrossFightServer.log.Error("Failed to start the server", e); result = false; } return(result); }
private void Init(Object sender, EventArgs e) { LogProvider.Default = new LogProvider(new LogConfig { UseMessageBox = true, LogView = LogView, UseLogView = true, FilePath = @".\log\", UseFile = true }); var log = LogProvider.Default; this.runmgr = new RunMgr(); Web.Server.WebServer.Runmgr = this.runmgr; new Thread(() => { if (!Sql_DbObject.TryConnection()) { log.Error("Fail to connect to SQL!"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to to connect to SQL!"); } if (!LanguageMgr.Load()) { log.Error("Fail to load language"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load language"); } if (!MapMgr.Init()) { log.Error("Fail to load map"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load map"); } if (!ItemMgr.Init()) { log.Error("Fail to load item"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load item"); } if (!PropItemMgr.Init()) { log.Error("Fail to load propitem"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load propitem"); } if (!BallMgr.Init()) { log.Error("Fail to load ball"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load ball"); } if (!DropMgr.Init()) { log.Error("Fail to load drop"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load drop"); } if (!NPCInfoMgr.Init()) { log.Error("Fail to load npc"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load npc"); } if (!ItemBoxMgr.Init()) { log.Error("Fail to load itembox"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load itembox"); } flag = true; }).Start(); Thread thread = new Thread(run); thread.Start(); }