/// <summary> /// 根据配置文件初始化匹配管理器 /// 该方法由Server 唯一调用 /// </summary> public bool Initialize(int serverId) { //初始化匹配队列字典 m_gameMatchPlayerCtxQueDic = new ConcurrentDictionary <int, GameMatchPlayerContextQueue>(); //初始化队伍字典 m_teamDic = new ConcurrentDictionary <UInt64, MatchTeam>(); //获取关卡配置文件,获取所有的游戏匹配信息 m_gameBarrierConfigs = GameServer.Instance.m_gameServerGlobalConfig.BarrierConfigs; //获取队伍配置文件 m_gameMatchTeamConfig = GameServer.Instance.m_gameServerGlobalConfig.GameMatchTeam; //根据配置文件初始化若干个匹配队列 存入字典中 foreach (var config in m_gameBarrierConfigs) { //配置关卡Id 关卡等级 关卡容纳人数 var queue = new GameMatchPlayerContextQueue(config.Id, config.Level, config.MemberCount, this); m_gameMatchPlayerCtxQueDic.TryAdd(config.Id, queue); } //初始化设置Id生成工具 ps:id由线程安全进行累加 m_roomIdFactory = new SessionIdFactory(serverId); return(true); }
public void Initialize(Type playerContextType, Int32 serverId, Int32 sizeMax) { // 保存最终PlayerContext的类型 m_contextType = playerContextType; // 保存最大现场个数 m_sizeMax = sizeMax; /// 测试给定的类型是否符合规范 IManagedContext newCtx = Activator.CreateInstance(m_contextType) as IManagedContext; if (newCtx == null) { throw new ArgumentException("PlayerContextManager::Initialize The type of playerContextType is not inherit from IManagedPlayerContext。"); } // 构造sessionidFactory m_sessionIdFactory = new SessionIdFactory(serverId); /// 创建字典对象 m_playerSid2CtxDic = new ConcurrentDictionary <UInt64, IManagedContext>(); m_playerCtxName2CtxDic = new ConcurrentDictionary <String, IManagedContext>(); }