private void __onJoin(NetworkMessage netMsg) { Message.Join join = netMsg.ReadMessage <Message.Join>(); float f = Random.Range(0, 10); join.pos = new Vector3(f, f, f); join.direction = new Vector3(f, f, f); NetworkServer.SendToAll(MessageType.Join, join); Message.GetOthers n = new Message.GetOthers(); Player[] array = new Player[playerDic.Count]; playerDic.Values.CopyTo(array, 0); n.playerList = new List <Player>(array); NetworkServer.SendToClient(netMsg.conn.connectionId, MessageType.GetOthers, n); if (!playerDic.ContainsKey(netMsg.conn.connectionId)) { Player p = new Player(); p.playerId = join.playerId; p.pos = join.pos; p.direction = join.direction; playerDic.Add(netMsg.conn.connectionId, p); } }
private void __onGetOthers(NetworkMessage netMsg) { Message.GetOthers notify = netMsg.ReadMessage <Message.GetOthers>(); for (int i = 0; i < notify.playerList.Count; i++) { GameManager.Instance.AddPlayer(notify.playerList[i]); } }