public int ExitRoom(WebPlayer webPlayer) { var ret = -1; var py = this.GetPlayer(webPlayer.Id); if (py == null) { return(ret); } ret = 1; RemovePlayer(webPlayer.Id); Log.Debug($"{webPlayer.Id}退出房间:{RoomId}"); var rpd = webPlayer.GetIBehaviour <RoomPlayerBv>(); SendToAllPlayer(Msg_Json.Create_Msg_Json(NetOpCode.RoomPlayerLeave_Msg, new RoomPlayerLeave_Msg { RoomPlayer_Data = rpd.RoomPlayer_Data })); { //广播消息 //SendToAllPlayer() } return(ret); }
protected override void Run(WebPlayer webpy, JObject message) { var enterRoom_Res = new EnterRoom_Res(); var enterRoom_Req = message.ToObject <EnterRoom_Req>(); enterRoom_Res.Res = GameMainEntry.Instance.SiloClientModule.ITableRoomEntry.Join(enterRoom_Req.TableUser_Data).Result; if (enterRoom_Res.Res > 0)//加入房间成功 { enterRoom_Res.TableRoomInfo = GameMainEntry.Instance.SiloClientModule.ITableRoomEntry.GetUserTableRoomInfo(enterRoom_Req.TableUser_Data.Id).Result; } webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.EnterRoom_Res, enterRoom_Res)); /* * var rpbv= webpy.GetIBehaviour<RoomPlayerBv>(); * if(rpbv == null) * { * //Log.Debug("没有加入房间"); * rpbv = new RoomPlayerBv(); * rpbv.RoomPlayer_Data = enterRoom_Req.RoomPlayer_Data; * webpy.AddIBehaviour(rpbv); * } * else * { * rpbv.RoomPlayer_Data = enterRoom_Req.RoomPlayer_Data; * } * * enterRoom_Res.Res = GameMainEntry.Instance.RoomModule.EnterRoom(webpy); * if (enterRoom_Res.Res > 0) * { * var tr = GameMainEntry.Instance.RoomModule.GetTableRoom(rpbv.RoomId); * enterRoom_Res.Ls_RoomPlayer_Data = tr.GetRoomPlayer_Data(); * } */ }
public int EnterTeam(WebPlayer webPlayer) { var ret = -1; var py = this.GetPlayer(webPlayer.Id); if (py != null) { ret = 2;//已经在房间中 return(ret); } //广播加入 var tpb = webPlayer.GetIBehaviour <TeamPlayerBv>(); tpb.TeamId = this.TeamId; tpb.TeamPlayer_Data.TeamId = this.TeamId; SendToAllPlayer(Msg_Json.Create_Msg_Json(NetOpCode.TeamPlayerJoin_Msg, new TeamPlayerJoin_Msg { TeamPlayer_Data = tpb.TeamPlayer_Data })); Dict_Rp.Add(webPlayer.Id, webPlayer); Log.Debug($"{webPlayer.Id}加入队伍:{TeamId}"); ret = 1; return(ret); }
public int EnterRoom(WebPlayer webPlayer) { var ret = -1; var py = this.GetPlayer(webPlayer.Id); if (py != null) { ret = 2;//已经在房间中 return(ret); } //广播加入 var rpd = webPlayer.GetIBehaviour <RoomPlayerBv>(); rpd.RoomId = this.RoomId; rpd.RoomPlayer_Data.RoomId = this.RoomId; SendToAllPlayer(Msg_Json.Create_Msg_Json(NetOpCode.RoomPlayerJoin_Msg, new RoomPlayerJoin_Msg { RoomPlayer_Data = rpd.RoomPlayer_Data })); Dict_Rp.Add(webPlayer.Id, webPlayer); Log.Debug($"{webPlayer.Id}加入房间:{RoomId}"); ret = 1; return(ret); }
protected override void Run(WebPlayer webpy, JObject message) { var enterTeam_Res = new EnterTeam_Res(); var enterTeam_Req = message.ToObject <EnterTeam_Req>(); var tpbv = webpy.GetIBehaviour <TeamPlayerBv>(); if (tpbv == null) { //Log.Debug("没有加入房间"); tpbv = new TeamPlayerBv(); tpbv.TeamPlayer_Data = enterTeam_Req.TeamPlayer_Data; webpy.AddIBehaviour(tpbv); } else { tpbv.TeamPlayer_Data = enterTeam_Req.TeamPlayer_Data; } enterTeam_Res.Res = GameMainEntry.Instance.TeamModule.EnterTeam(webpy); if (enterTeam_Res.Res > 0) { var tr = GameMainEntry.Instance.TeamModule.GetTeam(tpbv.TeamId); enterTeam_Res.Ls_TeamPlayer_Data = tr.GetTeamPlayer_Data(); enterTeam_Res.TeamId = tr.TeamId; } webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.EnterTeam_Res, enterTeam_Res)); }
//解散小队 public void DisBand() { foreach (var vk in this.Dict_Rp) { vk.Value.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.TeamDisband_Msg, new TeamDisband_Msg())); } this.CloseTeam(); }
protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message) { var roomLoading_Req = message.ToObject <RoomLoading_Req>(); rpb.RoomPlayer_Data.IPercent = roomLoading_Req.IPercent; var roomLoading_Res = new RoomLoading_Res(); roomLoading_Res.Id = rpb.RoomPlayer_Data.Id; roomLoading_Res.IPercent = rpb.RoomPlayer_Data.IPercent; tr.SendToAllPlayer(Msg_Json.Create_Msg_Json(NetOpCode.RoomLoading_Res, roomLoading_Res)); }
/* * protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message) * { * * var exitTeam_Res = new ExitTeam_Res() { Res = -1 }; * var exitTeam_Req = message.ToObject<ExitTeam_Req>(); * var tpbv = webpy.GetIBehaviour<TeamPlayerBv>(); * exitTeam_Res.Res = GameMainEntry.Instance.TeamModule.ExitRoom(webpy); * webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.ExitTeam_Res, exitTeam_Res)); * * }*/ protected override void Run(WebPlayer webpy, JObject message) { var exitTeam_Res = new ExitTeam_Res() { Res = -1 }; var exitTeam_Req = message.ToObject <ExitTeam_Req>(); exitTeam_Res.Res = GameMainEntry.Instance.TeamModule.ExitRoom(webpy); webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.ExitTeam_Res, exitTeam_Res)); }
/* * protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr , JObject message) * { * var exitRoom_Res = new ExitRoom_Res() { Res = -1 }; * var exitRoom_Req = message.ToObject<ExitRoom_Req>(); * * exitRoom_Res.Res = GameMainEntry.Instance.SiloClientModule.ITableRoomEntry.Exit(exitRoom_Req.Id).Result; * * webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.ExitRoom_Res, exitRoom_Res)); * * var rpbv = webpy.GetIBehaviour<RoomPlayerBv>(); * exitRoom_Res.Res = GameMainEntry.Instance.RoomModule.ExitRoom(webpy); * webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.ExitRoom_Res, exitRoom_Res)); * * }*/ protected override void Run(WebPlayer webpy, JObject message) { var exitRoom_Res = new ExitRoom_Res() { Res = -1 }; //var exitRoom_Req = message.ToObject<ExitRoom_Req>(); exitRoom_Res.Res = GameMainEntry.Instance.SiloClientModule.ITableRoomEntry.Exit(webpy.Id).Result; webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.ExitRoom_Res, exitRoom_Res)); }
protected void SendReadyFinish() { var readyfinish_req = new RoomReadyFinish_Req(); foreach (var rp in m_Dict_Rp) { var rpd = rp.Value.GetIBehaviour <RoomPlayerBv>(); readyfinish_req.Ls_StartGame_Data.Add(rpd.StartGame_Data); rpd.RoomPlayerState = ERoomPlayerState.E_InGame; } this.SendToAllPlayer(Msg_Json.Create_Msg_Json(NetOpCode.RoomReadyFinish_Req, readyfinish_req)); }
protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message) { var roomReady_Req = message.ToObject <RoomReady_Req>(); rpb.RoomPlayer_Data.IsReady = roomReady_Req.IsReady; var roomReady_Res = new RoomReady_Res(); roomReady_Res.Id = rpb.RoomPlayer_Data.Id; roomReady_Res.IsReady = rpb.RoomPlayer_Data.IsReady; rpb.StartGame_Data = roomReady_Req.StartGame_Data; tr.SendToAllPlayer(Msg_Json.Create_Msg_Json(NetOpCode.RoomReady_Res, roomReady_Res)); }
protected override void Run(IWebSocketSession session, JObject message) { var bys = Msg_Json.Create_Msg_Json(NetOpCode.Ping_Msg, message); session.Context.WebSocket.Send(bys); var py = GameMainEntry.Instance.PlayerModule.Session_Pys.GetValueByKey(session.ID); if (py != null) { py.LastActiveTime = DateTime.Now; GameMainEntry.Instance.SiloClientModule.INetUserEntry.Ping(py.Id).Wait(); } }
protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message) { if (tr.RoomState == ERoomState.ERoom_InGame || tr.RoomState == ERoomState.ERoom_GameOver) { GetNextFrame_Req getNextFrame_Req = message.ToObject <GetNextFrame_Req>(); GetNextFrame_Res getNextFrame_Res = new GetNextFrame_Res(); var tmp_fms = tr.ServerPlayer.PlayerRecoder.GetCurToEndFrame(getNextFrame_Req.CurFrameId); foreach (var fm in tmp_fms) { getNextFrame_Res.ListFrame.Add(fm); } webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.GetNextFrame_Res, getNextFrame_Res)); } }
protected override void Run(IWebSocketSession session, JObject message) { var login_req = message.ToObject <Login_Req>(); var py = GameMainEntry.Instance.PlayerModule.GetPlayer(login_req.Id); if (py == null) { py = GameMainEntry.Instance.PlayerModule.CreatePlayer(login_req.Id); } Log.Debug($"Py{py.Id}:登录成功"); py.CheckNetUser().Wait(); GameMainEntry.Instance.PlayerModule.SetSession_Py(py, session); py.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.Login_Res, new Login_Res { Res = 1 })); }
public int ExitTeam(WebPlayer webPlayer) { var ret = -1; var py = this.GetPlayer(webPlayer.Id); if (py == null) { return(ret); } ret = 1; RemovePlayer(webPlayer.Id); Log.Debug($"{webPlayer.Id}退出队伍:{TeamId}"); var tpb = webPlayer.GetIBehaviour <TeamPlayerBv>(); SendToAllPlayer(Msg_Json.Create_Msg_Json(NetOpCode.TeamPlayerLeave_Msg, new TeamPlayerLeave_Msg { TeamPlayer_Data = tpb.TeamPlayer_Data })); return(ret); }
protected override void Run(WebPlayer webpy, JObject message) { var rpbv = webpy.GetIBehaviour <RoomPlayerBv>(); if (rpbv == null) { webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.NeedEnterRoom_Msg, new NeedEnterRoom_Msg())); return; } var tr = GameMainEntry.Instance.RoomModule.GetTableRoom(rpbv.RoomId); if (tr == null) { Log.Debug("没有房间"); webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.NeedEnterRoom_Msg, new NeedEnterRoom_Msg())); return; } this.Run(webpy, rpbv, tr, message); }
protected override void Run(WebPlayer webpy, JObject message) { var tpbv = webpy.GetIBehaviour <TeamPlayerBv>(); if (tpbv == null) { webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.NeedTeam_Msg, new NeedEnterRoom_Msg())); return; } var team = GameMainEntry.Instance.TeamModule.GetTeam(tpbv.TeamId); if (team == null) { webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.NeedTeam_Msg, new NeedEnterRoom_Msg())); return; } var matchStart_Res = new MatchStart_Res() { Res = -1 }; var matchStart_Req = message.ToObject <MatchStart_Req>(); if (matchStart_Req.MatchingType == (int)EMatchingType.Matching_Friend)//好友对战 { if (team.Dict_Rp.Count == GameConstant.FriendsBattlePlayerNub) { var tr = GameMainEntry.Instance.RoomModule.GetAvailableTableRoom(); if (tr != null) { foreach (var vk in team.Dict_Rp) { var rpbv2 = vk.Value.GetIBehaviour <RoomPlayerBv>(); var tpbv2 = vk.Value.GetIBehaviour <TeamPlayerBv>(); tr.EnterRoom(vk.Value); } } } webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.MatchStart_Res, matchStart_Res)); return; } }
protected virtual void SendReLogin(IWebSocketSession session) { var bys = Msg_Json.Create_Msg_Json <NeedLogin_Msg>(NetOpCode.NeedLogin_Msg, new NeedLogin_Msg()); session.Context.WebSocket.Send(bys); }