private void NewPlayer(byte msgId, NetworkReader reader, IPEndPoint ep) { var playerData = new PlayerData(); var msg = new Msg.NewPlayer() { playerData = playerData }; msg.Deserialize(reader); ActorMgr.NewPlayer(playerData, this.fd == playerData.fd); }
private void NewConnection(byte msgId, NetworkReader reader, IPEndPoint ep) { var fd = ep.ToString(); { var msg = new Msg.Connect() { fd = fd, playerDatas = ActorMgr.ToPlayerDatas() }; this.server.Send(ep, MsgId.Connect, msg); } if (!this.isPlayer && this.server.ConnectionCount == 1) { return; } { var x = Mathf.Lerp(-2, 2, Random.value); var z = Mathf.Lerp(-2, 2, Random.value); var msg = new Msg.NewPlayer() { playerData = new PlayerData() { fd = fd, position = new Vector3(x, 1, z) } }; this.server.SendToAll(MsgId.NewPlayer, msg); } print("New Client: " + fd); }