コード例 #1
0
ファイル: Program.cs プロジェクト: zaq1xsw/DogSE
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new FrmMain());

            ServerConfig.Tcp = new[]
            {
                new TcpConfig
                {
                    Host = "127.0.0.1",
                    Port = 4530,
                }
            };

            Logs.ConfigLogFile("tradeage.log");
            Logs.AddAppender(new ConsoleAppender());

            GameServerService.IsConsoleRun = true;
            var world = new WorldBase();
            world.IsAutoRegisterMessage = false;
            world.NetStateDisconnect += world_NetStateDisconnect;
            GameServerService.AfterModuleInit = () =>
            {
                ServerLogicProtoclRegister.Register(world.GetModules(), world.PacketHandlers);
                ClientProxyRegister.Register();
                return true;
            };
            LogicModule.Prints();
            GameServerService.StartGame(world);
        }
コード例 #2
0
ファイル: GameServerService.cs プロジェクト: RainsSoft/DogSE
        /// <summary>
        ///     开启游戏
        /// </summary>
        /// <remarks>
        ///     游戏启动执行顺序
        ///     1.FirstInit
        ///     2.InitTemplate
        ///     3.LoadDefaultGameData
        ///     4.BeforeModuleInit
        ///     5.world.Start()
        ///     6.AfterModuleInit
        /// </remarks>
        /// <param name="world"></param>
        public static void StartGame(WorldBase world)
        {
            if (world == null)
                throw new NullReferenceException("world");

            s_world = world;

            RunType = ServerStateType.Starting;

            //  先加载最基础的配置文件
            StaticConfigFileManager.LoadData();

            if (FirstInit != null)
                IsErrorToExitProgram(FirstInit());

            if (InitTemplate != null)
                IsErrorToExitProgram(InitTemplate());

            if (LoadDefaultGameData != null)
                IsErrorToExitProgram(LoadDefaultGameData());

            if (BeforeModuleInit != null)
                IsErrorToExitProgram(BeforeModuleInit());

            world.StartWorld();

            if (AfterModuleInit != null)
                IsErrorToExitProgram(AfterModuleInit());

            RunType = ServerStateType.Runing;

            if (IsConsoleRun)
            {
                StartCommandlinesDisposal();
            }
        }