void OnClientReady(ClientReady ready, Connection conn) { if (conn.state == ConnState.WaitForReady) { conn.state = ConnState.InGame; Player p = lm.AddPlayer(ControllerType.Remote, NewPlayerId(), conn.playerName); conn.playerId = p.id; //发送游戏状态 InitServerGameInfo info = new InitServerGameInfo(); //此客户端的玩家信息 info.clientLocalPlayer = p.AchievePlayerInfo(); //其他玩家的信息 info.elsePlayers = new PlayerInfo[lm.playerCount - 1]; lm.AchievePlayerInfo(info.elsePlayers, p.id); Server.SendMessage(new GameMsg(GameMsg.MsgType.InitServerGameInfo, info), conn.connId, UnityEngine.Networking.QosType.ReliableSequenced); //通知其他玩家 PlayerJoin join = new PlayerJoin(); join.info = info.clientLocalPlayer; GameMsg msg = new GameMsg(GameMsg.MsgType.PlayerJoin, join); SendToAllClientsInGame(msg, conn.connId, UnityEngine.Networking.QosType.ReliableSequenced); } }