public void UpdatePlayerStatistic(int value, Action onSuccess, Action onCancel = null) { var request = new UpdatePlayerStatisticsRequest { Statistics = new List <StatisticUpdate>() { new StatisticUpdate { StatisticName = StatisticName, Value = value } } }; PlayFabClientAPI.UpdatePlayerStatistics( request, _result => { DebugLogUpdateStatistics(_result); onSuccess?.Invoke(); }, _error => { var report = _error.GenerateErrorReport(); Debug.LogError(report); ErrorDialogView.Show("UpdatePlayerStatistics failed", report, () => { UpdatePlayerStatistic(value, onSuccess, onCancel); }, onCancel); }); }
public void Request(Action <string> onReceiveDisplayName) { var connectingView = ConnectingView.Show(); PlayFabClientAPI.GetPlayerProfile( new GetPlayerProfileRequest(), _result => { var playerProfile = _result.PlayerProfile; Debug.Log(string.Format("{0}:{1}", playerProfile.PlayerId, playerProfile.DisplayName)); connectingView.Close(); if (onReceiveDisplayName != null) { onReceiveDisplayName(playerProfile.DisplayName); } }, _error => { var report = _error.GenerateErrorReport(); Debug.LogError(report); connectingView.Close(); ErrorDialogView.Show("GetPlayerProfile failed", report, () => { Request(onReceiveDisplayName); }, true); }); }
public void Request(Action <List <PlayerLeaderboardEntry> > onReceiveLeaderboard, Action onCancel = null) { var connectingView = ConnectingView.Show(); var request = new GetLeaderboardRequest { MaxResultsCount = MaxEntriesCount, StatisticName = StatisticName, }; PlayFabClientAPI.GetLeaderboard( request, _result => { DebugLogLeaderboard(_result); connectingView.Close(); onReceiveLeaderboard?.Invoke(_result.Leaderboard); }, _error => { var report = _error.GenerateErrorReport(); Debug.LogError(report); connectingView.Close(); ErrorDialogView.Show("GetLeaderboard failed", report, () => { Request(onReceiveLeaderboard, onCancel); }, onCancel); }); }
public IDialogService Create(string text = null) { var view = new ErrorDialogView(text); view.ShowDialog(); return(view); }
private async void ToServerAsync() { (string, string, string, bool)dataTuple; string resultCode = ""; string name = ""; string gender = ""; bool isHavePastMessage = false; string login = Login ?? ""; string password = new System.Net.NetworkCredential(string.Empty, Password).Password; await Task.Run(async() => { try { _serverWorker = ServerWorker.NewInstance(); dataTuple = await _serverWorker.AuthorizationAsync(login, GetHash(password)); resultCode = dataTuple.Item1; name = dataTuple.Item2; gender = dataTuple.Item3; isHavePastMessage = dataTuple.Item4; if (resultCode == "28") { if (IsRemember) { await Task.Run(() => _logicDb.AddNewUser(login, password)); } UserContainer.Login = Login; UserContainer.Password = Password; UserContainer.Gender = gender; } else { IsNotAuthorization = true; await Task.Run(() => _logicDb.DeleteUser(login, password)); } } catch { // ignore } }); if (resultCode == "28") { MainChatPageViewModel mainChatPageViewModel = new MainChatPageViewModel(name); NewPage = new MainChatPageView(); NewPage.DataContext = mainChatPageViewModel; mainChatPageViewModel.StartLoad(isHavePastMessage); Login = ""; _viewWindow.PasswordWrite(""); IsRemember = false; } else if (resultCode == "") { ErrorDialogView errorDialogView = new ErrorDialogView(new ErrorDialogViewModel("Ошибка подключения к серверу!")); errorDialogView.ShowDialog(); } IsCanClick = true; }
void OnUpdateFailure(PlayFabError error) { var report = error.GenerateErrorReport(); Debug.LogError(report); connectingView.Close(); ErrorDialogView.Show("UpdateUserTitleDisplayName failed", report, OnClickOk, true); }
void GetTitleData(Action <Dictionary <string, string> > onSuccess) { var connectingView = ConnectingView.Show(); PlayFabClientAPI.GetTitleData( new GetTitleDataRequest(), _result => { DebugLogTitleData(_result); connectingView.Close(); onSuccess?.Invoke(_result.Data); }, _error => { var report = _error.GenerateErrorReport(); Debug.LogError(report); connectingView.Close(); ErrorDialogView.Show("GetTitleData failed", report, () => { GetTitleData(onSuccess); }, true); }); }
/// <summary> /// Shows a message box if an unhandled exception is thrown /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { var errorDialog = new ErrorDialogView(e.Exception); errorDialog.ShowDialog(); }
void OnLoginFailure(string report) { ErrorDialogView.Show("Login failed", report, () => { SceneManager.LoadScene(this.GetType().Name); }); }