public RoomOnePeople(RoomOnePeople other) { this.Id = other.Id; this.Level = other.Level; this.Name = other.Name; this.State = other.State; }
private async ETVoid RunAsync(Session session, C2G_EnterBattle message, Action <G2C_EnterBattle> reply) { G2C_EnterBattle response = new G2C_EnterBattle(); try { // 这个组件是在登陆成功的时候挂上的 Player player = session.GetComponent <SessionPlayerComponent>().Player; // 在Battle服务器创建战斗 IPEndPoint mapAddress = StartConfigComponent.Instance.MapConfigs[0].GetComponent <InnerConfig>().IPEndPoint; Session battleSession = Game.Scene.GetComponent <NetInnerComponent>().Get(mapAddress); Room room = Game.Scene.GetComponent <RoomComponent>().Get(message.BattleId); RoomOnePeople info = room.GetPlayerRoomInfo(player.Id); G2B_CreateTank msg = new G2B_CreateTank(); msg.BattleId = message.BattleId; msg.PlayerId = player.Id; msg.GateSessionId = session.InstanceId; msg.Camp = info.Camp; msg.Name = player.UserDB.GetComponent <UserBaseComponent>().UserName; msg.Level = player.UserDB.GetComponent <UserBaseComponent>().Level; B2G_CreateTank createTank = (B2G_CreateTank)await battleSession.Call(msg); player.TankId = createTank.TankId; response.TankId = createTank.TankId; reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override void Run(Session session, C2G_Ready message) { Room room = ETModel.Game.Scene.GetComponent <RoomComponent>().Get(message.RoomId); long playerId = session.GetComponent <SessionPlayerComponent>().Player.Id; RoomOnePeople roomOnePeople = room.GetPlayerRoomInfo(playerId); if (message.Opt == Ready_OPT.Ready) { roomOnePeople.State = true; } else { roomOnePeople.State = false; } room.BroadcastRoomDetailInfo(); }
protected async ETVoid RunAsync(Session session, C2G_StartGame message) { long roomId = message.RoomId; Room room = Game.Scene.GetComponent <RoomComponent>().Get(roomId); int errCode = 0; if (!room.CanStartGame(ref errCode)) { Player player = session.GetComponent <SessionPlayerComponent>().Player; player.Send_PopMessage(errCode); return; } IPEndPoint mapAddress = StartConfigComponent.Instance.MapConfigs[0].GetComponent <InnerConfig>().IPEndPoint; Session mapSession = Game.Scene.GetComponent <NetInnerComponent>().Get(mapAddress); G2B_CreateBattle msg = new G2B_CreateBattle(); msg.RoomId = roomId; msg.LeftCamp = new List <RoomOnePeople>(); msg.RightCamp = new List <RoomOnePeople>(); foreach (RoomOnePeople onePeople in room.GetLeftCamp()) { RoomOnePeople tmp = new RoomOnePeople(onePeople); msg.LeftCamp.Add(tmp); } foreach (RoomOnePeople onePeople in room.GetRightCamp()) { RoomOnePeople tmp = new RoomOnePeople(onePeople); msg.RightCamp.Add(tmp); } if (true) { msg.RoomSimpleInfo = new RoomSimpleInfo(); RoomSimpleInfo roomSimpleInfo = msg.RoomSimpleInfo; roomSimpleInfo.RoomId = room.Id; roomSimpleInfo.PeopleNum = room.PeopleNum; roomSimpleInfo.MapId = room.MapTableId; roomSimpleInfo.BigModel = (int)room.BigModel; roomSimpleInfo.SmallModel = room.SmallMode; roomSimpleInfo.RoomName = room.RoomName; roomSimpleInfo.State = room.State; roomSimpleInfo.SerialNumber = room.SerialNumber; roomSimpleInfo.RoomOwnerId = room.OwnerId; } await mapSession.Call(msg); room.State = 2; room.GetAll(); room.BroadCastStartGame(); BroadcastMessage.Send_G2C_Rooms(); }