Skip to content

Commit

Permalink
Fixed "AWFUL" when no notes
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Mar 13, 2023
1 parent d39bb03 commit 0a0d54f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 336 deletions.
76 changes: 41 additions & 35 deletions Assets/Script/PlayMode/MicPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,38 +207,40 @@ private void Update() {
if (eventInfo.name == "vocal_endPhrase") {
float bestPercent = 0f;

// Reset and see if we failed or not
foreach (var playerInfo in micInputs) {
float mul = GetSingTimeMultiplier(playerInfo.player.chosenDifficulty);
float percent = playerInfo.singProgress / (sectionSingTime * mul);

if (percent >= 1f) {
playerInfo.sectionsHit++;
} else {
playerInfo.secitonsFailed++;
if (sectionSingTime != 0f) {
// Reset and see if we failed or not
foreach (var playerInfo in micInputs) {
float mul = GetSingTimeMultiplier(playerInfo.player.chosenDifficulty);
float percent = playerInfo.singProgress / (sectionSingTime * mul);

if (percent >= 1f) {
playerInfo.sectionsHit++;
} else {
playerInfo.secitonsFailed++;
}

if (playerInfo.singProgress / sectionSingTime >= 1f) {
bestPercent = float.PositiveInfinity;
} else if (percent > bestPercent) {
bestPercent = percent;
}

playerInfo.singProgress = 0f;
}

if (playerInfo.singProgress / sectionSingTime >= 1f) {
bestPercent = float.PositiveInfinity;
} else if (percent > bestPercent) {
bestPercent = percent;
}

playerInfo.singProgress = 0f;
// Set preformance text
GameUI.Instance.vocalPreformanceText.text = bestPercent switch {
float.PositiveInfinity => "PERFECT!",
>= 1f => "AWESOME!",
>= 0.8f => "STRONG",
>= 0.7f => "GOOD",
>= 0.6f => "OKAY",
>= 0.1f => "MESSY",
_ => "AWFUL"
};
GameUI.Instance.vocalPreformanceText.color = Color.white;
}

// Set preformance text
GameUI.Instance.vocalPreformanceText.text = bestPercent switch {
float.PositiveInfinity => "PERFECT!",
>= 1f => "AWESOME!",
>= 0.8f => "STRONG",
>= 0.7f => "GOOD",
>= 0.6f => "OKAY",
>= 0.1f => "MESSY",
_ => "AWFUL"
};
GameUI.Instance.vocalPreformanceText.color = Color.white;

// Calculate the new sing time
CalculateSectionSingTime(Play.Instance.SongTime);
}
Expand Down Expand Up @@ -285,8 +287,8 @@ private void Update() {
Difficulty.EASY => 4f,
Difficulty.MEDIUM => 4f,
Difficulty.HARD => 3f,
Difficulty.EXPERT => 2f,
Difficulty.EXPERT_PLUS => 0.5f,
Difficulty.EXPERT => 2.5f,
Difficulty.EXPERT_PLUS => 1f,
_ => throw new System.Exception("Unreachable.")
};

Expand Down Expand Up @@ -337,7 +339,11 @@ private void Update() {

// Update bar
float singTimeModifier = GetSingTimeMultiplier(player.chosenDifficulty);
playerInfo.barMesh.material.SetFloat("Fill", playerInfo.singProgress / (sectionSingTime * singTimeModifier));
if (sectionSingTime != 0f) {
playerInfo.barMesh.material.SetFloat("Fill", playerInfo.singProgress / (sectionSingTime * singTimeModifier));
} else {
playerInfo.barMesh.material.SetFloat("Fill", 0f);
}
}

// Update preformance text fading
Expand Down Expand Up @@ -396,10 +402,10 @@ private void CalculateSectionSingTime(float start) {
private float GetSingTimeMultiplier(Difficulty diff) {
return diff switch {
Difficulty.EASY => 0.45f,
Difficulty.MEDIUM => 0.55f,
Difficulty.HARD => 0.6f,
Difficulty.EXPERT => 0.65f,
Difficulty.EXPERT_PLUS => 0.85f,
Difficulty.MEDIUM => 0.5f,
Difficulty.HARD => 0.55f,
Difficulty.EXPERT => 0.6f,
Difficulty.EXPERT_PLUS => 0.65f,
_ => throw new System.Exception("Unreachable.")
};
}
Expand Down
Loading

0 comments on commit 0a0d54f

Please sign in to comment.