Esempio n. 1
0
 public override void updateUi(object param)
 {
     base.updateUi(param);
     KeyValuePair<ChatGameController.UiUpdates, object> info = (KeyValuePair<ChatGameController.UiUpdates, object>)param;
     switch (info.Key)
     {
         case ChatGameController.UiUpdates.UpdateUsersList:
             displayeUsers();
             break;
         case ChatGameController.UiUpdates.GameIsReady:
             stopWait();
             break;
         case ChatGameController.UiUpdates.NewUser:
             {
                 ChatGameController.ChatUser user = (ChatGameController.ChatUser)info.Value;
                 addUser(user.firstName, user.secondName, user.iconUri, user.userId);
             }
             break;
         case ChatGameController.UiUpdates.UserRemoved:
             {
                 if (selectedUser!= null && selectedUser.userId == (int)info.Value)
                 {
                     selectedUser = null;
                     clearMessages();
                 }
                 displayeUsers();
             }
             break;
         case ChatGameController.UiUpdates.UserUpdated:
             {
                 ChatGameController.ChatUser user = (ChatGameController.ChatUser)info.Value;
                 updateUser(user.firstName, user.secondName, user.iconUri, user.userId);
             }
             break;
         case ChatGameController.UiUpdates.ReceivedMessage:
             {
                 ChatGameController.ChatDialogMessage message = (ChatGameController.ChatDialogMessage)info.Value;
                 if (selectedUser != null && selectedUser.userId == message.senderId)
                 {
                     addMessage(selectedUser.firstName, message.message, false);
                 }
             }
             break;
     }
 }
Esempio n. 2
0
    public void selectUser(RectTransform menuItem, int userId)
    {
        //unselect user
        for (int i = 0; i < usersList.childCount; i++)
        {
            GameObject go = usersList.GetChild(i).gameObject;
            go.GetComponent<Image>().color = unselectedUserColor;
        }
        clearMessages();
        selectedUser = chatController.getUser(userId);

        menuItem.GetComponent<Image>().color = selectedUserColor;

        ChatGameController.ChatDialogWithUser dialog = chatController.getDialog(userId);
        if (dialog != null)
        {
            UserInfo userInfo = SystemController.get().getUserInfo();
            foreach (ChatGameController.ChatDialogMessage message in dialog.messages)
            {
                if (userInfo.userId == message.senderId)
                {
                    addMessage(userInfo.firstName, message.message, true);
                }
                else
                {
                    addMessage(dialog.withUser.firstName, message.message, false);
                }

            }
        }
    }