Esempio n. 1
0
        // 游戏逻辑
        public static void BuildLogicComponents(GameServer gs)
        {
            BC <SessionContainer>();  // 会话容器
            BC <LoginManager>();      // 登录
            BC <UnitConfigManager>(); // 配置表
            BC <UserManager>();

            BC <BattleRoomManager>(); // 战斗房间管理
            BC <MatchBoard>();        // 对战匹配
            BC <UnitFactory>();       // 地图单位工厂
            BC <UnitConfiguration>(); // 战场单位配置管理

            var uc = new UserContainer(new MySqlDbPersistence <User, string>(
                                           "scm", "127.0.0.1", "root", "123456",
                                           @"Users", "CREATE TABLE Users(ID VARCHAR(100) BINARY, Data MediumBlob, PRIMARY KEY(ID ASC));",
                                           null, (usr) =>
            {
                var buff = new WriteBuffer();
                usr.Serialize(buff);
                return(buff.Data);
            }, (data) =>
            {
                var rb  = new RingBuffer(data);
                var usr = new User();
                usr.Deserialize(rb);
                return(usr);
            }, null));

            srv.Add("UserContainer", uc);
        }
Esempio n. 2
0
        // 初始化
        public override void Init()
        {
            SC = GetCom <SessionContainer>();
            UP = GetCom <UserPort>();
            UC = GetCom <UserContainer>();
            var nc = GetCom <NetCore>();

            nc.OnDisconnected += OnDisconnected;

            UP.OnRequest("Login", OnUserLoginMsg);

            // 登录日志
            SrvLogger = GetCom <ServerBusinessLogger <LoginInfo> >();

            //  问卷
            QRC = GetCom <QuestionnaireResultContainer>();
        }