示例#1
0
        private void JoinLobby(object parameter)
        {
            Guid lobbyId = (Guid)parameter;

            DinnergeddonServiceReference.Lobby lobbyToJoin = _proxy.GetLobbyById(lobbyId);
            Guid userId = customPrincipal.Identity.Id;

            if (!IsJoinedInALobby(userId))
            {
                //_proxy.GetLobbyById(lobbyId);

                if (lobbyToJoin.IsPrivate)
                {
                    pd = new InputPasswordDialog()
                    {
                        DataContext = new InputPasswordViewModel()
                    };
                    pd.Show();
                    string password = "";
                    Mediator.Subscribe("PassWordCorrect", new Action <object>((x) =>
                    {
                        App.Current.Dispatcher.Invoke((Action) delegate
                        {
                            pd.Close();
                            //_proxy.JoinLobby(userId, lobbyId, password);
                        });
                        password = x as String;

                        JoinPrivateLobby(customPrincipal.Identity.Id, lobbyId, password);
                    }));
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
                                                                                                { lobbyToJoin = _proxy.JoinLobby(userId, lobbyId); }));

                    if (lobbyToJoin == null)
                    {
                        MessageBox.Show("Joining this lobby is not possible", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        OpenLobby(lobbyToJoin.Id);
                    }
                }
            }

            else
            {
                if (IsJoinedInTheLobby(userId, lobbyId))
                {
                    // _proxy.GetLobbyById(lobbyId);
                    OpenLobby(lobbyId);
                }
                else
                {
                    MessageBox.Show("You already joined a lobby", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
        private void LobbyJoined(object parameter)
        {
            Guid lobbyId = (Guid)parameter;

            DinnergeddonServiceReference.Lobby lobby = _proxy.GetLobbyById(lobbyId);
            _lobby    = lobby;
            LobbyName = _lobby.Name;

            JoinedPlayers = new ObservableCollection <Account>(_lobby.Players.ToList());
            //  LobbyServiceReference.Lobby joinedLobby = _proxy.GetLobbyById((Guid)parameter);
        }
示例#3
0
 private void SetLobby(object parameter)
 {
     _lobby = _proxy.GetLobbyById((Guid)parameter);
 }