Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement, reorganize, and fix a number of solo handling things #446

Merged
merged 11 commits into from
Jun 9, 2023
Prev Previous commit
Next Next commit
Move solo box text formatting to TrackView
TheNathannator committed Jun 9, 2023
commit 9f52852ed153b4e1f8322013d8d1ac73fb620fac
18 changes: 3 additions & 15 deletions Assets/Script/PlayMode/AbstractTrack.cs
Original file line number Diff line number Diff line change
@@ -86,9 +86,8 @@ public abstract class AbstractTrack : MonoBehaviour {
protected bool soloInProgress = false;
protected int soloNoteCount = -1;
protected int soloNotesHit = 0;
private int soloHitPercent = 0;
private int SoloHitPercent => soloNoteCount > 0 ? Mathf.FloorToInt((float) soloNotesHit / soloNoteCount * 100f) : 0;
private int lastHit = -1;
private double soloPtsEarned;

private bool FullCombo = true;

@@ -617,20 +616,9 @@ private void UpdateSolo() {
// );
// commonTrack.soloText.gameObject.SetActive(true);

soloHitPercent = Mathf.FloorToInt((float) soloNotesHit / soloNoteCount * 100f);
commonTrack.TrackView.SetSoloBox(soloHitPercent + "%", $"{soloNotesHit}/{soloNoteCount}");
commonTrack.TrackView.SetSoloBox(SoloHitPercent, soloNotesHit, soloNoteCount);
} else if (soloInProgress) {
commonTrack.TrackView.HideSoloBox(soloHitPercent + "%", soloHitPercent switch {
69 => "<i>NICE</i>\nSOLO",

>= 100 => "PERFECT\nSOLO!",
>= 95 => "AWESOME\nSOLO!",
>= 90 => "GREAT\nSOLO!",
>= 80 => "GOOD\nSOLO!",
>= 70 => "SOLID\nSOLO",
>= 60 => "OKAY\nSOLO",
_ => "MESSY\nSOLO",
});
commonTrack.TrackView.HideSoloBox(SoloHitPercent);

soloInProgress = false;
}
31 changes: 23 additions & 8 deletions Assets/Script/UI/TrackView.cs
Original file line number Diff line number Diff line change
@@ -50,34 +50,49 @@ public void UpdateSizing(int trackCount) {
TrackImage.transform.localScale = new Vector3(scale, scale, scale);
}

public void SetSoloBox(string topText, string bottomText) {
public void SetSoloBox(int hitPercent, int notesHit, int totalNotes) {
// Stop hide coroutine if we were previously hiding
if (_soloBoxHide != null) {
StopCoroutine(_soloBoxHide);
_soloBoxHide = null;
}

string percentageText = $"{hitPercent}%";
string noteCountText = $"{notesHit}/{totalNotes}";

_soloBox.gameObject.SetActive(true);
_soloBoxCanvasGroup.alpha = 1f;
_soloBox.sprite = _normalSoloBox;

_soloFullText.text = string.Empty;
_soloTopText.text = topText;
_soloBottomText.text = bottomText;
_soloTopText.text = percentageText;
_soloBottomText.text = noteCountText;
}

public void HideSoloBox(string percent, string fullText) {
public void HideSoloBox(int finalPercent) {
string percentageText = $"{finalPercent}%";

_soloTopText.text = string.Empty;
_soloBottomText.text = string.Empty;
_soloFullText.text = percent;
_soloFullText.text = percentageText;

_soloBoxHide = StartCoroutine(HideSoloBoxCoroutine(fullText));
_soloBoxHide = StartCoroutine(HideSoloBoxCoroutine(finalPercent));
}

private IEnumerator HideSoloBoxCoroutine(string fullText) {
private IEnumerator HideSoloBoxCoroutine(int finalPercent) {
yield return new WaitForSeconds(1f);

_soloFullText.text = fullText;
string resultText = finalPercent switch {
>= 100 => "PERFECT\nSOLO!",
>= 95 => "AWESOME\nSOLO!",
>= 90 => "GREAT\nSOLO!",
>= 80 => "GOOD\nSOLO!",
>= 70 => "SOLID\nSOLO",
69 => "<i>NICE</i>\nSOLO",
>= 60 => "OKAY\nSOLO",
_ => "MESSY\nSOLO",
};
_soloFullText.text = resultText;

yield return new WaitForSeconds(1f);