public override void OnScreenChangeStarted(Screen from, Screen to) { base.OnScreenChangeStarted(from, to); if (from == this && to != null) { NavigationBackdrop.Instance.FadeBrightness(0, onComplete: () => { TranslucentCover.Clear(); NavigationBackdrop.Instance.FadeBrightness(1); }); } }
public void GoBack() { NavigationBackdrop.Instance.FadeBrightness(0, onComplete: () => { TranslucentCover.Clear(); NavigationBackdrop.Instance.FadeBrightness(1); }); Context.TierState = null; Context.ScreenManager.ChangeScreen(TierSelectionScreen.Id, ScreenTransition.Out, willDestroy: true); Context.AudioManager.Get("LevelStart").Play(); }
public override async void OnScreenBecameActive() { base.OnScreenBecameActive(); // TODO: Most code here is the same as the one in ResultScreen.cs. Refactor? gameState = Context.GameState; Context.GameState = null; // Load translucent cover var path = "file://" + gameState.Level.Path + gameState.Level.Meta.background.path; TranslucentCover.Set(await Context.AssetMemory.LoadAsset <Sprite>(path, AssetTag.GameCover)); // Update performance info scoreText.text = Mathf.FloorToInt((float)gameState.Score).ToString("D6"); accuracyText.text = "RESULT_X_ACCURACY".Get((Math.Floor(gameState.Accuracy * 100 * 100) / 100).ToString("0.00")); if (Mathf.Approximately((float)gameState.Accuracy, 1)) { accuracyText.text = "RESULT_FULL_ACCURACY".Get(); } maxComboText.text = "RESULT_X_COMBO".Get(gameState.MaxCombo); if (gameState.GradeCounts[NoteGrade.Bad] == 0 && gameState.GradeCounts[NoteGrade.Miss] == 0) { maxComboText.text = "RESULT_FULL_COMBO".Get(); } var scoreGrade = ScoreGrades.From(gameState.Score); gradeText.text = scoreGrade.ToString(); gradeText.GetComponent <GradientMeshEffect>().SetGradient(scoreGrade.GetGradient()); if (scoreGrade == ScoreGrade.MAX || scoreGrade == ScoreGrade.SSS) { scoreText.GetComponent <GradientMeshEffect>().SetGradient(scoreGrade.GetGradient()); } else { scoreText.GetComponent <GradientMeshEffect>().enabled = false; } standardMetricText.text = $"<b>Perfect</b> {gameState.GradeCounts[NoteGrade.Perfect]} " + $"<b>Great</b> {gameState.GradeCounts[NoteGrade.Great]} " + $"<b>Good</b> {gameState.GradeCounts[NoteGrade.Good]} " + $"<b>Bad</b> {gameState.GradeCounts[NoteGrade.Bad]} " + $"<b>Miss</b> {gameState.GradeCounts[NoteGrade.Miss]}"; advancedMetricText.text = $"<b>Early</b> {gameState.EarlyCount} " + $"<b>Late</b> {gameState.LateCount} " + $"<b>{"RESULT_AVG_TIMING_ERR".Get()}</b> {gameState.AverageTimingError:0.000}s " + $"<b>{"RESULT_STD_TIMING_ERR".Get()}</b> {gameState.StandardTimingError:0.000}s"; if (!Context.Player.Settings.DisplayEarlyLateIndicators) { advancedMetricText.text = ""; } tierState = Context.TierState; modeText.text = tierState.Tier.Meta.name; var stage = tierState.CurrentStage; difficultyBall.SetModel(stage.Difficulty, stage.DifficultyLevel); stageTitleText.text = stage.Level.Meta.title; if (tierState.IsFailed) { retryButton.StartPulsing(); } else { nextStageButton.StartPulsing(); } nextStageButton.State = tierState.IsFailed ? CircleButtonState.GoBack : (tierState.IsCompleted ? CircleButtonState.Finish : CircleButtonState.NextStage); nextStageButton.interactableMonoBehavior.onPointerClick.SetListener(_ => { Context.Haptic(HapticTypes.SoftImpact, true); nextStageButton.StopPulsing(); if (tierState.IsFailed) { GoBack(); } else { if (tierState.IsCompleted) { Finish(); } else { NextStage(); } } }); retryButton.State = CircleButtonState.Retry; retryButton.interactableMonoBehavior.onPointerClick.SetListener(_ => { Context.Haptic(HapticTypes.SoftImpact, true); retryButton.StopPulsing(); Retry(); }); // Update criterion entries foreach (Transform child in criterionEntryHolder.transform) { Destroy(child.gameObject); } foreach (var criterion in Context.TierState.Criteria) { var entry = Instantiate(criterionEntryPrefab, criterionEntryHolder.transform) .GetComponent <CriterionEntry>(); entry.SetModel(criterion.Description, criterion.Judge(Context.TierState)); } criterionEntryHolder.transform.RebuildLayout(); NavigationBackdrop.Instance.Apply(it => { it.IsBlurred = true; it.FadeBrightness(1, 0.8f); }); ProfileWidget.Instance.Enter(); if (tierState.IsFailed) { Toast.Next(Toast.Status.Failure, "TOAST_TIER_FAILED".Get()); } if (!tierState.IsCompleted && !tierState.IsFailed) { proceedToNextStageTime = DateTimeOffset.UtcNow.AddSeconds(IntermissionSeconds); nextBroadcastCountdownTime = DateTimeOffset.UtcNow; } else { proceedToNextStageTime = DateTimeOffset.MaxValue; nextBroadcastCountdownTime = DateTimeOffset.MaxValue; } }
public override async void OnScreenBecameActive() { base.OnScreenBecameActive(); gameState = Context.GameState; if (gameState == null) { // Test mode Debug.Log("Result not set, entering test mode..."); gameState = new GameState(GameMode.Practice, Context.SelectedLevel, Context.SelectedDifficulty); Context.OnlinePlayer.OnAuthenticated.AddListener(() => { rankingsTab.UpdateRankings(Context.SelectedLevel.Id, Context.SelectedDifficulty.Id); ratingTab.UpdateLevelRating(Context.SelectedLevel.Id); UploadRecord(); }); } Context.GameState = null; nextButton.State = CircleButtonState.Next; nextButton.StartPulsing(); nextButton.interactableMonoBehavior.onPointerClick.SetListener(_ => { Context.Haptic(HapticTypes.SoftImpact, true); nextButton.StopPulsing(); Done(); }); retryButton.State = CircleButtonState.Retry; retryButton.interactableMonoBehavior.onPointerClick.SetListener(_ => { Context.Haptic(HapticTypes.SoftImpact, true); retryButton.StopPulsing(); Retry(); }); // Load translucent cover var path = "file://" + Context.SelectedLevel.Path + Context.SelectedLevel.Meta.background.path; TranslucentCover.Set(await Context.AssetMemory.LoadAsset <Sprite>(path, AssetTag.GameCover)); NavigationBackdrop.Instance.Apply(it => { it.IsBlurred = true; it.FadeBrightness(1, 0.8f); }); // Update performance info scoreText.text = Mathf.FloorToInt((float)gameState.Score).ToString("D6"); accuracyText.text = "RESULT_X_ACCURACY".Get((Math.Floor(gameState.Accuracy * 100 * 100) / 100).ToString("0.00")); if (Mathf.Approximately((float)gameState.Accuracy, 1)) { accuracyText.text = "RESULT_FULL_ACCURACY".Get(); } maxComboText.text = "RESULT_X_COMBO".Get(gameState.MaxCombo); if (gameState.GradeCounts[NoteGrade.Bad] == 0 && gameState.GradeCounts[NoteGrade.Miss] == 0) { maxComboText.text = "RESULT_FULL_COMBO".Get(); } var scoreGrade = ScoreGrades.From(gameState.Score); gradeText.text = scoreGrade.ToString(); gradeText.GetComponent <GradientMeshEffect>().SetGradient(scoreGrade.GetGradient()); if (scoreGrade == ScoreGrade.MAX || scoreGrade == ScoreGrade.SSS) { scoreText.GetComponent <GradientMeshEffect>().SetGradient(scoreGrade.GetGradient()); } else { scoreText.GetComponent <GradientMeshEffect>().enabled = false; } standardMetricText.text = $"<b>Perfect</b> {gameState.GradeCounts[NoteGrade.Perfect]} " + $"<b>Great</b> {gameState.GradeCounts[NoteGrade.Great]} " + $"<b>Good</b> {gameState.GradeCounts[NoteGrade.Good]} " + $"<b>Bad</b> {gameState.GradeCounts[NoteGrade.Bad]} " + $"<b>Miss</b> {gameState.GradeCounts[NoteGrade.Miss]}"; advancedMetricText.text = $"<b>Early</b> {gameState.EarlyCount} " + $"<b>Late</b> {gameState.LateCount} " + $"<b>{"RESULT_AVG_TIMING_ERR".Get()}</b> {gameState.AverageTimingError:0.000}s " + $"<b>{"RESULT_STD_TIMING_ERR".Get()}</b> {gameState.StandardTimingError:0.000}s"; if (!Context.Player.Settings.DisplayEarlyLateIndicators) { advancedMetricText.text = ""; } var record = gameState.Level.Record; record.IncrementPlayCountByOne(gameState.Difficulty); newBestText.text = record.TrySaveBestPerformance(gameState.Mode, gameState.Difficulty, (int)gameState.Score, gameState.Accuracy); gameState.Level.SaveRecord(); shareButton.onPointerClick.SetListener(_ => StartCoroutine(Share())); ProfileWidget.Instance.Enter(); upperRightColumn.Enter(); if (Context.IsOnline() && Context.OnlinePlayer.IsAuthenticated) { UploadRecord(); } else { EnterControls(); } if (Context.IsOnline()) { rankingsIcon.SetActive(true); ratingIcon.SetActive(true); if (gameState.Mode == GameMode.Standard && !Context.OnlinePlayer.IsAuthenticated) { rankingsTab.UpdateRankings(gameState.Level.Id, gameState.Difficulty.Id); } ratingTab.UpdateLevelRating(gameState.Level.Id) .Then(it => { if (it == null) { return; } if (Context.OnlinePlayer.IsAuthenticated && it.rating <= 0 && ScoreGrades.From(gameState.Score) >= ScoreGrade.A) { // Invoke the rate dialog ratingTab.rateLevelElement.rateButton.onPointerClick.Invoke(null); } }); } else { rankingsIcon.SetActive(false); ratingIcon.SetActive(false); } }