Ejemplo n.º 1
0
        private void OnFriendRemoval(FriendRemoval message)
        {
            var friend = message.Login;

            FriendListController.RemoveItem(friend);
            chatRecords.Remove(friend);
            if (friend == FriendName.text)
            {
                // Unity dropdown crashed if we disable chat window without closing the dropdown first
                StartCoroutine(CloseChatWindowWithDelay());
                FriendName.text = "";
            }
            GameManager.Instance.RemoveFriend(friend);
            foreach (IOnFriendsChangedListener listener in onFriendsChangedListeners)
            {
                listener.OnFriendRemoved();
            }

            UpdatePlayersOnSameNetwork();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles selecting option from dropdown in chat window.
        /// </summary>
        /// <param name="option">id of selected option</param>
        public void OnDropdownOption(int option)
        {
            // reset dropdown value to make it work like a button
            FriendActionsDropdown.value = ChatDropdownOption.CANCEL;
            switch (option)
            {
            case ChatDropdownOption.SHOW_PROFILE:
                ConnectionHandler.Instance.OpenUrlAuthorized("profile/" + Uri.EscapeDataString(FriendName.text));
                break;

            case ChatDropdownOption.CHALLENGE:
                ChallengeController.Instance.Show();
                break;

            case ChatDropdownOption.OFFER_FRUITON:
                Scenes.Load(Scenes.LOCAL_TRADE_SCENE, Scenes.OFFERED_PLAYER_LOGIN, SelectedPlayerLogin);
                break;

            case ChatDropdownOption.DELETE_FRIEND:
                FriendRemoval removalMessage = new FriendRemoval
                {
                    Login = FriendName.text
                };

                WrapperMessage ws = new WrapperMessage
                {
                    FriendRemoval = removalMessage
                };
                ConnectionHandler.Instance.SendWebsocketMessage(ws);
                OnFriendRemoval(removalMessage);
                break;

            case ChatDropdownOption.CANCEL:
                return;
            }
        }