From b8df0d1a26b07950d02366808e7f2eb48e287f33 Mon Sep 17 00:00:00 2001 From: minenice55 Date: Tue, 24 Jan 2023 20:10:24 -0500 Subject: [PATCH] record accuracy for playthrough --- Assets/Scripts/GameManager.cs | 10 ++++++++-- Assets/Scripts/Games/Minigame.cs | 5 +++++ Assets/Scripts/Games/PlayerActionEvent.cs | 6 ++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 3d8c53099..27be2f87f 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -203,9 +203,10 @@ namespace HeavenStudio } } - public static void ScoreInputAccuracy(double accuracy, float weight = 1) + public void ScoreInputAccuracy(double accuracy, bool late, double weight = 1) { - + totalInputs += weight; + totalPlayerAccuracy += accuracy * weight; } public void SeekAheadAndPreload(double start, float seekTime = 8f) @@ -387,6 +388,10 @@ namespace HeavenStudio canInput = true; inputOffsetSamples.Clear(); averageInputOffset = 0; + + totalInputs = 0; + totalPlayerAccuracy = 0; + StartCoroutine(PlayCo(beat)); onBeatChanged?.Invoke(beat); } @@ -427,6 +432,7 @@ namespace HeavenStudio KillAllSounds(); Debug.Log($"Average input offset for playthrough: {averageInputOffset}ms"); + Debug.Log($"Accuracy for playthrough: {(PlayerAccuracy * 100) : 0.00}"); if (playOnStart) { diff --git a/Assets/Scripts/Games/Minigame.cs b/Assets/Scripts/Games/Minigame.cs index 367364f24..c505302bc 100644 --- a/Assets/Scripts/Games/Minigame.cs +++ b/Assets/Scripts/Games/Minigame.cs @@ -251,6 +251,11 @@ namespace HeavenStudio.Games return null; } + public void ScoreMiss(double weight) + { + GameManager.instance.ScoreInputAccuracy(0, true, weight); + } + private void OnDestroy() { foreach (var evt in scheduledInputs) { diff --git a/Assets/Scripts/Games/PlayerActionEvent.cs b/Assets/Scripts/Games/PlayerActionEvent.cs index aa0639811..53e7d56e8 100644 --- a/Assets/Scripts/Games/PlayerActionEvent.cs +++ b/Assets/Scripts/Games/PlayerActionEvent.cs @@ -165,9 +165,9 @@ namespace HeavenStudio.Games GameManager.instance.AvgInputOffset = offset; OnHit(this, (float) state); - if (countsForAccuracy && !(noAutoplay || autoplayOnly)) - TimeToAccuracy(time); CleanUp(); + if (countsForAccuracy && !(noAutoplay || autoplayOnly)) + GameManager.instance.ScoreInputAccuracy(TimeToAccuracy(time), time > 1.0, 1.0); } else { Blank(); @@ -233,6 +233,8 @@ namespace HeavenStudio.Games } CleanUp(); + if (countsForAccuracy && !(noAutoplay || autoplayOnly)) + GameManager.instance.ScoreInputAccuracy(0, true, 1.0); } public void Blank()