protected override void Run(Session session, C2G_ChatMessage message) { G2C_ChatMessage msg = new G2C_ChatMessage(); msg.ChatStr = message.ChatStr; msg.ChatType = message.ChatType; Player player = session.GetComponent <SessionPlayerComponent>().Player; msg.SourceId = player.Id; msg.SourceName = player.UserDB.GetComponent <UserBaseComponent>().UserName; if (message.ChatType == ChatType.Room) { long roomId = session.GetComponent <SessionPlayerComponent>().Player.RoomId; Room room = Game.Scene.GetComponent <RoomComponent>().Get(roomId); msg.TankCamp = (TankCamp)room.GetPlayerRoomInfo(player.Id).Camp; room.BroadCast(msg); } else { MessageHelper.BroadcastPlayer(msg); } }
public static void Send_G2C_Rooms() { // 下发所有房间信息 G2C_Rooms msg = new G2C_Rooms(); msg.RoomSimpleInfo = new RepeatedField <RoomSimpleInfo>(); Room[] rooms = Game.Scene.GetComponent <RoomComponent>().GetAll; foreach (Room room in rooms) { RoomSimpleInfo simpleInfo = new RoomSimpleInfo(); simpleInfo.RoomId = room.Id; simpleInfo.PeopleNum = room.PeopleNum; simpleInfo.MapId = room.MapTableId; simpleInfo.BigModel = (int)room.BigModel; simpleInfo.SmallModel = room.SmallMode; simpleInfo.RoomName = room.RoomName; simpleInfo.State = room.State; simpleInfo.SerialNumber = room.SerialNumber; simpleInfo.ExistNum = room.Count; msg.RoomSimpleInfo.Add(simpleInfo); } MessageHelper.BroadcastPlayer(msg); }