Skip to content

Commit

Permalink
Make SP be awarded on hitting last note of phrase
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelgoulart committed Apr 11, 2023
1 parent f77a475 commit 1078228
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
12 changes: 11 additions & 1 deletion Assets/Script/PlayMode/AbstractTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public abstract class AbstractTrack : MonoBehaviour {
protected List<NoteInfo> Chart => Play.Instance.chart
.GetChartByName(player.chosenInstrument)[(int) player.chosenDifficulty];

protected int visualChartIndex = 0;
protected int realChartIndex = 0;
protected int eventChartIndex = 0;
protected int currentChartIndex = 0;

[SerializeField]
protected Camera trackCamera;

Expand Down Expand Up @@ -201,7 +206,7 @@ private void UpdateMaterial() {

private void UpdateStarpower() {
// Update starpower region
if (StarpowerSection?.EndTime + Play.HIT_MARGIN < Play.Instance.SongTime) {
if (IsStarpowerHit()) {
StarpowerSection = null;
starpowerCharge += 0.25f;
}
Expand Down Expand Up @@ -254,5 +259,10 @@ private void StarpowerAction(InputStrategy inputStrategy) {
protected float CalcLagCompensation(float currentTime, float noteTime) {
return (currentTime - noteTime) * (player.trackSpeed / Play.speed);
}

private bool IsStarpowerHit() {
if (Chart.Count > currentChartIndex) return Chart[currentChartIndex].time >= StarpowerSection?.EndTime;
else return false;
}
}
}
6 changes: 2 additions & 4 deletions Assets/Script/PlayMode/DrumsTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ public sealed class DrumsTrack : AbstractTrack {
[SerializeField]
private ParticleGroup kickNoteParticles;

private int visualChartIndex = 0;
private int realChartIndex = 0;
private int eventChartIndex = 0;

private Queue<List<NoteInfo>> expectedHits = new();

private int notesHit = 0;
Expand Down Expand Up @@ -175,6 +171,7 @@ private void UpdateInput() {
// Call miss for each component
Combo = 0;
foreach (var hit in missedChord) {
currentChartIndex++;
notePool.MissNote(hit);
StopAudio = true;
}
Expand Down Expand Up @@ -237,6 +234,7 @@ private void DrumHitAction(int drum, bool cymbal) {
}

// Hit note
currentChartIndex++;
notePool.HitNote(hit);
StopAudio = false;

Expand Down
7 changes: 3 additions & 4 deletions Assets/Script/PlayMode/FiveFretTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ public class FiveFretTrack : AbstractTrack {
[SerializeField]
private ParticleGroup openNoteParticles;

private int visualChartIndex = 0;
private int realChartIndex = 0;
private int eventChartIndex = 0;

private Queue<List<NoteInfo>> expectedHits = new();
private List<List<NoteInfo>> allowedOverstrums = new();
private List<NoteInfo> heldNotes = new();
Expand Down Expand Up @@ -158,6 +154,7 @@ private void UpdateInput() {
// Call miss for each component
Combo = 0;
foreach (var hit in missedChord) {
currentChartIndex++;
notePool.MissNote(hit);
StopAudio = true;
}
Expand Down Expand Up @@ -213,6 +210,7 @@ private void UpdateInput() {
while (expectedHits.Peek() != chord) {
var missedChord = expectedHits.Dequeue();
foreach (var hit in missedChord) {
currentChartIndex++;
notePool.MissNote(hit);
}
}
Expand Down Expand Up @@ -253,6 +251,7 @@ private void UpdateInput() {

Combo++;
foreach (var hit in chord) {
currentChartIndex++;
// Hit notes
notePool.HitNote(hit);
StopAudio = false;
Expand Down
6 changes: 2 additions & 4 deletions Assets/Script/PlayMode/RealGuitarTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ public class RealGuitarTrack : AbstractTrack {
[SerializeField]
private Pool genericPool;

private int visualChartIndex = 0;
private int realChartIndex = 0;
private int eventChartIndex = 0;

private Queue<NoteInfo> expectedHits = new();
private List<NoteInfo> heldNotes = new();

Expand Down Expand Up @@ -153,6 +149,7 @@ private void UpdateInput() {
var missedNote = expectedHits.Dequeue();

// Call miss for each component
currentChartIndex++;
Combo = 0;
notePool.MissNote(missedNote);
StopAudio = true;
Expand Down Expand Up @@ -184,6 +181,7 @@ private void UpdateInput() {
}

// If so, hit!
currentChartIndex++;
expectedHits.Dequeue();

Combo++;
Expand Down

0 comments on commit 1078228

Please sign in to comment.