internal void MpveEndBattle(int kill_npc_ct) { if (this.CurrentState == RoomState.Finish || this.CurrentState == RoomState.Deactive) { return; } foreach (User user in room_users_) { if (user != null) { Msg_RL_UserQuit.Builder unqBuilder = Msg_RL_UserQuit.CreateBuilder(); unqBuilder.SetRoomID(cur_room_id_); unqBuilder.SetUserGuid(user.Guid); unqBuilder.SetIsBattleEnd(true); connector_.SendMsgToLobby(unqBuilder.Build()); } } //向Lobby发送战斗结束消息:RoomID,胜方阵营,开始时间,结束时间。。。 Msg_RL_BattleEnd.Builder beBuilder = Msg_RL_BattleEnd.CreateBuilder(); beBuilder.SetRoomID(RoomID); Msg_RL_BattleEnd.Types.WinnerCampEnum winCamp = Msg_RL_BattleEnd.Types.WinnerCampEnum.None; beBuilder.SetWinnerCamp(winCamp); //战斗数据 foreach (User user in room_users_) { if (user != null) { var battleRecord = user.Info.GetCombatStatisticInfo(); Msg_RL_UserBattleInfo.Builder ubrBuilder = Msg_RL_UserBattleInfo.CreateBuilder(); ubrBuilder.SetUserGuid(user.Guid); Msg_RL_UserBattleInfo.Types.BattleResultEnum result = Msg_RL_UserBattleInfo.Types.BattleResultEnum.Unfinish; if (kill_npc_ct > 0) { result = Msg_RL_UserBattleInfo.Types.BattleResultEnum.Win; } else { result = Msg_RL_UserBattleInfo.Types.BattleResultEnum.Lost; } ubrBuilder.SetBattleResult(result); ubrBuilder.SetMoney(user.Info.Money); CombatStatisticInfo combatInfo = user.Info.GetCombatStatisticInfo(); ubrBuilder.SetHitCount(combatInfo.HitCount); ubrBuilder.SetKillNpcCount(kill_npc_ct); ubrBuilder.SetMaxMultiHitCount(combatInfo.MaxMultiHitCount); ubrBuilder.SetTotalDamageToMyself(combatInfo.TotalDamageToMyself); ubrBuilder.SetTotalDamageFromMyself(combatInfo.TotalDamageFromMyself); beBuilder.AddUserBattleInfos(ubrBuilder.Build()); } } connector_.SendMsgToLobby(beBuilder.Build()); this.CurrentState = RoomState.Finish; m_FinishTime = TimeUtility.GetServerMilliseconds(); LogSys.Log(LOG_TYPE.DEBUG, "Room {0}({1}) MpveEndBattle.", RoomID, LocalID); }
internal void NoticeRoomClosing() { foreach (User user in room_users_) { if (user != null && (int)UserControlState.UserDropped == user.UserControlState) { Msg_RL_UserQuit.Builder unqBuilder = Msg_RL_UserQuit.CreateBuilder(); unqBuilder.SetRoomID(cur_room_id_); unqBuilder.SetUserGuid(user.Guid); unqBuilder.SetIsBattleEnd(true); connector_.SendMsgToLobby(unqBuilder.Build()); } } }
internal void DropUser(User user) { //向游戏客户端广播玩家掉线消息 Msg_CRC_Exit bd = new Msg_CRC_Exit(); bd.role_id = user.RoleId; user.BroadCastMsgToRoom(bd); //向Lobby发送玩家掉线消息 Msg_RL_UserQuit.Builder uaqBuilder = Msg_RL_UserQuit.CreateBuilder(); uaqBuilder.SetRoomID(cur_room_id_); uaqBuilder.SetUserGuid(user.Guid); uaqBuilder.SetIsBattleEnd(false); connector_.SendMsgToLobby(uaqBuilder.Build()); //控制状态改为掉线 user.UserControlState = (int)UserControlState.UserDropped; if (null != user.Info) { // user.Info.Suicide(); } LogSys.Log(LOG_TYPE.DEBUG, "Room {0} User {1}({2}) dropped.", RoomID, user.Guid, user.GetKey()); }