private void OnOtherDisconnect(uint id) { if (_avatarAreaManager.HasAvatarView(id)) { _avatarAreaManager.RemoveAvatarView(id); } }
private void sendObject(ISerializable pOutObject) { try { Debug.Log("Sending:" + pOutObject); Packet outPacket = new Packet(); outPacket.Write(pOutObject); StreamUtil.Write(_client.GetStream(), outPacket.GetBytes()); } catch (Exception e) { //for quicker testing, we reconnect if something goes wrong. Debug.Log(e.Message); _client.Close(); for (int i = 0; i < _avatarAreaManager.GetAllAvatarIds().Count; i++) { _avatarAreaManager.RemoveAvatarView(i); } connectToServer(); } }
public void RemoveRandomAvatar() { int randomAvatarId = getRandomAvatorId(); if (randomAvatarId == -1) { return; } _avatarAreaManager.RemoveAvatarView(randomAvatarId); }
private void ProcessObject(object obj) { switch (obj) { case HelloWorld helloWorld: selfUserId = helloWorld.SelfUserId; serverTimeout = helloWorld.Timeout; receivedUserId = true; Debug.Log("Processed HelloWorld"); break; case Message message: var target = avatarAreaManager.GetAvatarView(message.UserId); target.Say(message.Text); Debug.Log("Processed Message"); break; case ClientJoined clientJoined: var avatarView = avatarAreaManager.AddAvatarView(clientJoined.UserId); avatarView.SetSkin(clientJoined.SkinId); avatarView.transform.position = new Vector3(clientJoined.X, clientJoined.Y, clientJoined.Z); if (receivedUserId && clientJoined.UserId == selfUserId) { avatarView.SetRingVisible(true); } Debug.Log("Processed ClientJoined"); break; case ClientLeft clientLeft: avatarAreaManager.RemoveAvatarView(clientLeft.UserId); Debug.Log("Processed ClientLeft"); break; case PositionChanged positionChanged: avatarAreaManager.GetAvatarView(positionChanged.UserId).Move(new Vector3(positionChanged.X, positionChanged.Y, positionChanged.Z)); Debug.Log("Processed PositionChanged"); break; case SkinChanged skinChanged: avatarAreaManager.GetAvatarView(skinChanged.UserId).SetSkin(skinChanged.SkinId); Debug.Log("Processed SkinChanged"); break; case ConnectedClients connectedClients: foreach (var client in connectedClients.Users) { var avatarView2 = avatarAreaManager.AddAvatarView(client.UserId); avatarView2.SetSkin(client.SkinId); avatarView2.transform.position = new Vector3(client.X, client.Y, client.Z); } Debug.Log("Processed ConnectedClients"); break; } }
private void removeAvatar(RemoveAvatar pRemoveAvatar) { _avatarAreaManager.RemoveAvatarView(pRemoveAvatar.id); }