Example #1
0
    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;
        }
    }
    public void MoveRandomAvatarToPosition(Vector3 pPosition)
    {
        int randomAvatarId = getRandomAvatorId();

        if (randomAvatarId == -1)
        {
            return;
        }

        AvatarView avatarView = _avatarAreaManager.GetAvatarView(randomAvatarId);

        avatarView.Move(pPosition);
    }
    private void showMessage(SimpleMessage messageObject)
    {
        List <int> allAvatarIds = _avatarAreaManager.GetAllAvatarIds();

        print(messageObject.id + "id");
        if (allAvatarIds.Count == 0)
        {
            Debug.Log("No avatars available to show text through:" + messageObject.text);
            return;
        }

        AvatarView avatarView = _avatarAreaManager.GetAvatarView(messageObject.id);

        avatarView.Say(messageObject.text);
    }
Example #4
0
    public void ChangeSkin()
    {
        AvatarView avatarView = _avatarAreaManager.GetAvatarView(client.data.id);
        ClientData data       = client.data;

        data.skinId = (uint)UnityEngine.Random.Range(0, 1000);
        client.data = data;
        avatarView.SetSkin((int)client.data.skinId);

        client.Write(new UpdateData(client.data));
    }
Example #5
0
    private void showMessage(string pText, int pID)
    {
        AvatarView avatarView = _avatarAreaManager.GetAvatarView(pID);

        avatarView.Say(pText);

        #region Given Code
        //List<int> allAvatarIds = _avatarAreaManager.GetAllAvatarIds();

        //if (allAvatarIds.Count == 0)
        //{
        //    Debug.Log("No avatars available to show text through:" + pText);
        //    return;
        //}

        //int randomAvatarId = allAvatarIds[UnityEngine.Random.Range(0, allAvatarIds.Count)];
        //AvatarView avatarView = _avatarAreaManager.GetAvatarView(randomAvatarId);
        //avatarView.Say(pText);
        #endregion
    }