private void SkipChallenge() { Device.BeginInvokeOnMainThread(async() => { _timer.Stop(); _hintDialog.Hide(); if (_showMessageIfSkipChallenge) { EnableButtons(false); //await _skipChallengeLimitDialog.Show(); await _skip3Dialog.Show(); _timer.Stop(); } else { await OnNextButtonPressedAnimations().ContinueWith(async(t) => { await Task.Delay(1); Device.BeginInvokeOnMainThread(() => ChallengeSkipped?.Invoke()); }); } FirebaseHelper firebaseHelper = new FirebaseHelper(); await firebaseHelper.UpdatePersonPruSal(8, _configuration.ReadProperty("docId")); }); }
private void ShowHint() { Device.BeginInvokeOnMainThread(async() => { _challengeResult.HintUsed = true; EnableButtons(false); _timer.Stop(); await _hintDialog.Show(); FirebaseHelper firebaseHelper = new FirebaseHelper(); await firebaseHelper.UpdatePersonPisSol(8, _configuration.ReadProperty("docId")); }); }
private void ShowResultSummary(bool timeOver, bool iveGotIt) { Device.BeginInvokeOnMainThread(async() => { _hintDialog.Hide(); _youveGotItDialog.Hide(); var iconName = timeOver ? "timeover.png" : iveGotIt ? "ivegotit.png" : "youlose.png"; summaryIcon.Source = ImageSource.FromFile(iconName); _challengeResult.TimeOver = timeOver; _challengeResult.ChallengeSuccess = iveGotIt; _challengeResult.ElapsedTime = _challenge.TimeInSeconds - _countDown; _challengeResult.ChallengePoints = iveGotIt ? (_challenge.Completed ? _challenge.PointsIfRepeat : (_challengeResult.HintUsed ? _challenge.PointsWithHint : _challenge.Points)) : _challenge.PenaltyPoints; _challengeResult.TotalPoints = Math.Max(0, _challengeResult.TotalPoints + _challengeResult.ChallengePoints); _resultSummaryDialogTitle.Text = timeOver ? $"¡Se acabó el tiempo!" : iveGotIt ? $"¡Prueba superada!" : $"Prueba no superada."; //_resultSummaryDialogPoints.Text = iveGotIt ? $"10 puntos" : $"0 puntos"; _resultSummaryDialogPoints.Text = $"{ _challengeResult.ChallengePoints } puntos"; _resultSummaryDialogPoints.TextColor = _configuration.Theme.SelectedBackgroundColor; await _resultSummaryDialog.Show(); FirebaseHelper firebaseHelper = new FirebaseHelper(); if (iveGotIt) { await firebaseHelper.UpdatePersonResAce(_configuration.ReadProperty("docId")); } else { await firebaseHelper.UpdatePersonResErr(_configuration.ReadProperty("docId")); } await firebaseHelper.UpdatePersonPruRea(_configuration.ReadProperty("docId")); }); }
//protected override async Task EntryAnimations() //{ // List<Task> tasks = new List<Task>(); // tasks.Add(base.EntryAnimations()); // if (NavigatingBack) // { // tasks.Add(emotionalIcon.AppearLeft(Configuration.AnimationSpeed)); // } // await Task.WhenAll(tasks); //} ////protected override async Task OnBackButtonPressedAnimations() ////{ //// await Task.WhenAll //// ( //// base.OnBackButtonPressedAnimations(), //// emotionalIcon.DisappearRight (Configuration.AnimationFastSpeed) //// ); ////} //protected override async Task OnNextButtonPressedAnimations() //{ // await Task.WhenAll // ( // base.OnNextButtonPressedAnimations(), // emotionalIcon.DisappearLeft(Configuration.AnimationSpeed) // ); //} private async void OnChallengeEnd(bool continuePlaying) { string rankingResponse = ChallengeEnd?.Invoke(_challengeResult); string[] parts = rankingResponse.Split(';'); string ranking = parts[0]; string leftPoints = parts[1]; //string ranking = "0"; //string leftPoints = "0"; _resultSummaryDialog.Hide(); if (!continuePlaying) { _finalResultSummaryDialogPoints.Text = $"{ _challengeResult.TotalPoints } puntos"; //_finalResultSummaryDialogPoints.Text = $"0 puntos"; string leftPointsMessage = leftPoints != "0" ? $"Te faltan { leftPoints } puntos para alcanzar la primera posición." : String.Empty; _finalResultSummaryDialogRanking.Text = $"Estás en la posición nº { ranking } del ranking. { leftPointsMessage }"; FirebaseHelper firebaseHelper = new FirebaseHelper(); await firebaseHelper.AddRankingThing(Convert.ToInt32(ranking), _challengeResult.TotalPoints, _configuration.UserId.ToString(), _configuration.ReadProperty("name")); await _finalResultSummaryDialog.Show(); await Task.Delay(1000); _finalResultSummaryDialog.Hide(); } await OnNextButtonPressedAnimations().ContinueWith((t) => { Device.BeginInvokeOnMainThread(() => ChallengeExit?.Invoke(continuePlaying)); }); }