private AvatarView SpawnAvatar(ClientData clientData) { AvatarView avatarView = _avatarAreaManager.AddAvatarView(clientData.id); avatarView.transform.localPosition = new Vector3(clientData.x, 0, clientData.y); //set a random skin avatarView.SetSkin((int)clientData.skinId); return(avatarView); }
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; } }
/** * Demonstrates how to create an Avatar with some id. */ public void AddRandomAvatar() { int avatarId = _lastAvatarId++; AvatarView avatarView = _avatarAreaManager.AddAvatarView(avatarId); avatarView.transform.localPosition = getRandomPosition(); //set a random skin avatarView.SetSkin(Random.Range(0, 1000)); }
/** * Demonstrates how to create an Avatar with some id. */ public void AddRandomAvatar() { //Note that normally you would use an id generated by the server, but now we use an ever increasing ID int avatarId = _lastAvatarId++; AvatarView avatarView = _avatarAreaManager.AddAvatarView(avatarId); avatarView.transform.localPosition = getRandomPosition(); //set a random skin avatarView.SetSkin(Random.Range(0, 1000)); }
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 handleNewAvatar(GetAvatars pGetAvatars) { foreach (AvatarObject avatar in pGetAvatars.AvatarList) { if (_avatarAreaManager.HasAvatarView(avatar.id)) { continue; } else { AvatarView avatarView = _avatarAreaManager.AddAvatarView(avatar.id); avatarView.transform.localPosition = new Vector3(avatar.xPos, avatar.yPos, avatar.zPos); avatarView.SetSkin(avatar.skindID); continue; } } }