private void RecycleRoomInfo(RoomInfo room) { room.Reset(); m_UnusedRoomInfos.Enqueue(room); }
//=================================================================== //以下为与RoomServer之间的消息通信 //响应RoomServer发来的房间创建反馈消息 internal void OnEnterSceneResult(ulong userGuid, int roomID, int result) { UserInfo user = LobbyServer.Instance.UserProcessScheduler.GetUserInfo(userGuid); if (user == null) { return; } if ((int)SceneOperationResultEnum.Success == result) { user.CurrentState = UserState.Room; user.CurrentRoomID = roomID; RoomInfo room = m_LobbyInfo.GetRoomByID(roomID); if (null != room) { RoomServerInfo svrInfo; if (m_LobbyInfo.RoomServerInfos.TryGetValue(room.RoomServerName, out svrInfo)) { if (null != svrInfo) { NodeMessage enterSceneResultMsg = new NodeMessage(LobbyMessageDefine.EnterSceneResult, user.Guid); GameFrameworkMessage.EnterSceneResult protoData = new GameFrameworkMessage.EnterSceneResult(); protoData.server_ip = svrInfo.ServerIp; protoData.server_port = svrInfo.ServerPort; protoData.key = user.Key; protoData.camp_id = user.CampId; protoData.scene_type = room.SceneType; protoData.result = (int)GeneralOperationResult.LC_Succeed; protoData.prime = Helper.Random.Next(2, 21); enterSceneResultMsg.m_ProtoData = protoData; LobbyServer.Instance.TransmitToWorld(user, enterSceneResultMsg); LogSys.Log(LOG_TYPE.INFO, "user enter field success! guid {0} room {1} result {2}", userGuid, roomID, (SceneOperationResultEnum)result); } else { LobbyServer.Instance.HighlightPrompt(user, 42);//进入游戏失败,请稍后重试 } } else { LobbyServer.Instance.HighlightPrompt(user, 42);//进入游戏失败,请稍后重试 } } else { LobbyServer.Instance.HighlightPrompt(user, 42);//进入游戏失败,请稍后重试 } } else { RoomInfo curRoom = user.Room; if (null != curRoom) { curRoom.DelUsers(userGuid); } user.CurrentState = UserState.Online; LogSys.Log(LOG_TYPE.INFO, "user enter field failed! guid {0} room {1} result {2}", userGuid, roomID, (SceneOperationResultEnum)result); LobbyServer.Instance.HighlightPrompt(user, 42);//进入游戏失败,请稍后重试 } }
private RoomInfo NewRoomInfo() { RoomInfo room = null; if (m_UnusedRoomInfos.Count > 0) { room = m_UnusedRoomInfos.Dequeue(); } else { room = new RoomInfo(); room.LobbyInfo = this; } room.CurrentState = RoomState.Prepare; return room; }
public void JoinRoom(RoomInfo roomInfo) { PhotonNetwork.JoinRoom(roomInfo.Name); }
//响应RoomServer发来的战斗结束消息 internal void OnRoomBattleEnd(Msg_RL_BattleEnd msg) { RoomInfo room = m_LobbyInfo.GetRoomByID(msg.RoomID); if (room != null) { //接收战斗数据 if (msg.WinnerCamp == Msg_RL_BattleEnd.Types.WinnerCampEnum.Red) { room.WinnerCamp = CampIdEnum.Red; } else if (msg.WinnerCamp == Msg_RL_BattleEnd.Types.WinnerCampEnum.Blue) { room.WinnerCamp = CampIdEnum.Blue; } else { room.WinnerCamp = CampIdEnum.Unkown; } int money_ct = 0; List <Teammate> teammate = new List <Teammate>(); foreach (var ubrMsg in msg.UserBattleInfosList) { UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(ubrMsg.UserGuid); if (user != null) { Teammate e = new Teammate(); e.Nick = user.Nickname; e.ResId = user.HeroId; e.Money = ubrMsg.Money; money_ct += ubrMsg.Money; teammate.Add(e); } } List <UserInfo> users = new List <UserInfo>(); foreach (var ubrMsg in msg.UserBattleInfosList) { UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(ubrMsg.UserGuid); if (user != null) { if (ubrMsg.BattleResult == Msg_RL_UserBattleInfo.Types.BattleResultEnum.Win) { user.CurrentBattleInfo.BattleResult = BattleResultEnum.Win; } else if (ubrMsg.BattleResult == Msg_RL_UserBattleInfo.Types.BattleResultEnum.Lost) { user.CurrentBattleInfo.BattleResult = BattleResultEnum.Lost; } else { user.CurrentBattleInfo.BattleResult = BattleResultEnum.Unfinish; } user.CurrentBattleInfo.TeamMate.AddRange(teammate); if (ubrMsg.HasKillNpcCount) { user.CurrentBattleInfo.KillNpcCount = ubrMsg.KillNpcCount; UpdateAttemptAward(ubrMsg.UserGuid, room.SceneType, ubrMsg.KillNpcCount); } user.CurrentBattleInfo.AddGold = ubrMsg.Money; user.CurrentBattleInfo.TotalGold = money_ct; user.CurrentBattleInfo.HitCount = ubrMsg.HitCount; user.CurrentBattleInfo.MaxMultiHitCount = ubrMsg.MaxMultiHitCount; user.CurrentBattleInfo.TotalDamageToMyself = ubrMsg.TotalDamageToMyself; user.CurrentBattleInfo.TotalDamageFromMyself = ubrMsg.TotalDamageFromMyself; users.Add(user); } } //处理战斗结果 room.ProcessBattleResult(users); //结束战斗 room.EndBattle(); } }