Skip to content

Commit

Permalink
Add combo to statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
HelloYeew committed Jul 24, 2024
1 parent 26f3e2c commit 110bd6b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Renako.Game/Graphics/Containers/PlayfieldContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public partial class PlayfieldContainer : Container
private RenakoSpriteText breakText;
private RenakoSpriteText hitText;
private RenakoSpriteText missText;
private RenakoSpriteText comboText;
private RenakoSpriteText clockText;

private const int fade_in_time = move_time / 2;
Expand Down Expand Up @@ -147,6 +148,12 @@ private void load(TextureStore textureStore, WorkingBeatmap workingBeatmap)
Origin = Anchor.TopRight,
Text = "Miss: 0"
},
comboText = new RenakoSpriteText()
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Text = "Combo: 0"
},
clockText = new RenakoSpriteText()
{
Anchor = Anchor.TopRight,
Expand All @@ -171,6 +178,7 @@ protected override void Update()
Logger.Log($"Missed note at {note.EndTime}", LoggingTarget.Runtime, LogLevel.Debug);
note.IsHit = true;
stats.Miss++;
stats.Combo = 0;
addHitResultAnimation(HitResult.Miss);
updateScoreText();
}
Expand Down Expand Up @@ -354,21 +362,25 @@ private void processHit(NoteLane lane)
if (diff < 50)
{
stats.Critical++;
stats.Combo++;
addHitResultAnimation(HitResult.Critical);
}
else if (diff < 100)
{
stats.Break++;
stats.Combo++;
addHitResultAnimation(HitResult.Break);
}
else if (diff < 200)
{
stats.Hit++;
stats.Combo++;
addHitResultAnimation(HitResult.Hit);
}
else
{
stats.Miss++;
stats.Combo = 0;
addHitResultAnimation(HitResult.Miss);
playHitAnimation = false;
}
Expand All @@ -391,6 +403,7 @@ private void updateScoreText()
breakText.Text = $"Break: {stats.Break}";
hitText.Text = $"Hit: {stats.Hit}";
missText.Text = $"Miss: {stats.Miss}";
comboText.Text = $"Combo: {stats.Combo}";
}

private enum HitResult
Expand Down Expand Up @@ -421,6 +434,7 @@ private class Statistics
public int Break { get; set; } // More than 50ms but less than 100ms
public int Hit { get; set; } // More than 100ms but less than 200ms
public int Miss { get; set; } // More than 200ms
public int Combo { get; set; } // Count of critical, break, and hit
}

private class PlayfieldNote
Expand Down

0 comments on commit 110bd6b

Please sign in to comment.