private void setLocalClient(SetClientParameters clientParameters) { //adds an avatar when you start { print(clientParameters.skin); AvatarView avatar = _avatarAreaManager.AddAvatarView(clientParameters.id); avatar.transform.localPosition = getRandomPosition(); avatar.SetSkin(clientParameters.skin); print("added avatar"); } }
private void processNewClients() { while (_listener.Pending()) { TcpClient clientToAdd = _listener.AcceptTcpClient(); byte[] inBytes = StreamUtil.Read(clientToAdd.GetStream()); Packet inPacket = new Packet(inBytes); ISerializable inObject = inPacket.ReadObject(); if (inObject is AddClient) { LobbyClient newClient = new LobbyClient(clientToAdd, currentClientId++); SetClientParameters newClientParameters = new SetClientParameters(); newClientParameters.id = newClient.id; newClientParameters.skin = newClient.id; //newClientParameters.skin = new System.Random().Next(1000)+_clients.Count; Console.WriteLine("joined client with id: " + newClientParameters.id + " and skin " + newClientParameters.skin); foreach (LobbyClient client in _clients) { sendObject(client.TcpClient, newClientParameters); } _clients.Add(newClient); foreach (LobbyClient client in _clients) { SetClientParameters parameters = new SetClientParameters(); parameters.id = client.id; parameters.skin = client.id; sendObject(newClient.TcpClient, parameters); } } Console.WriteLine("Accepted new client."); } }