internal static Msg_LR_RoomUserInfo BuildRoomUserInfo(UserInfo info, float x, float y) { //todo:加锁 Msg_LR_RoomUserInfo ruiBuilder = new Msg_LR_RoomUserInfo(); ruiBuilder.Guid = info.Guid; ruiBuilder.Nick = info.Nickname; ruiBuilder.Key = info.Key; ruiBuilder.Hero = info.HeroId; ruiBuilder.Camp = info.CampId; ruiBuilder.IsMachine = false; ruiBuilder.Level = info.Level; ruiBuilder.SummonerSkillId = info.SummonerSkillId; /// int memberCount = info.MemberInfos.Count; if (memberCount > 0) { Msg_LR_RoomUserInfo.MemberInfo[] memberList = new Msg_LR_RoomUserInfo.MemberInfo[memberCount]; for (int i = 0; i < memberCount; ++i) { memberList[i] = new Msg_LR_RoomUserInfo.MemberInfo(); memberList[i].Hero = info.MemberInfos[i].HeroId; memberList[i].Level = info.MemberInfos[i].Level; } } if (x > 0 && y > 0) { ruiBuilder.EnterX = x; ruiBuilder.EnterY = y; } return ruiBuilder; }
//-------------------------------------------------------------------------------------------------------------------------- //这些方法是一些工具方法,后面需要重新考虑并发相关的处理。 //-------------------------------------------------------------------------------------------------------------------------- internal UserInfo AddOrUpdateUserInfo(Msg_LB_BigworldUserBaseInfo baseUserInfo, Msg_LR_RoomUserInfo roomUserInfo, int leftLifeTime) { ulong guid = roomUserInfo.Guid; UserInfo info; if (!m_UserInfos.TryGetValue(guid, out info)) { info = NewUserInfo(); info.Key = GenerateKey(); } info.BaseUserInfo = baseUserInfo; info.RoomUserInfo = roomUserInfo; info.LeftLife = leftLifeTime; info.CurrentState = UserState.Online; m_UserInfos.AddOrUpdate(guid, info, (g, u) => info); m_GuidByNickname.AddOrUpdate(info.Nickname, guid, (n, g) => guid); ActivateUserGuid(guid); return info; }