diff --git a/Assets/Scripts/Conductor.cs b/Assets/Scripts/Conductor.cs index 93b760df7..1acfb49b0 100644 --- a/Assets/Scripts/Conductor.cs +++ b/Assets/Scripts/Conductor.cs @@ -189,23 +189,20 @@ namespace HeavenStudio { Util.Jukebox.PlayOneShot("metronome"); } - else if (songPosition <= lastReportedBeat) + else if (songPositionInBeats < lastReportedBeat) { - lastReportedBeat = (songPosition - (songPosition % secPerBeat)); + lastReportedBeat = Mathf.Round(songPositionInBeats); } } } } - public bool ReportBeat(ref float lastReportedBeat, float offset = 0, bool shiftBeatToOffset = false) + public bool ReportBeat(ref float lastReportedBeat, float offset = 0, bool shiftBeatToOffset = true) { - bool result = songPosition > (lastReportedBeat + offset) + secPerBeat; - if (result == true) + bool result = songPositionInBeats + (shiftBeatToOffset ? offset : 0f) >= (lastReportedBeat) + 1f; + if (result) { - lastReportedBeat = (songPosition - (songPosition % secPerBeat)); - - if (!shiftBeatToOffset) - lastReportedBeat += offset; + lastReportedBeat += 1f; } return result; } diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 92f1a83d6..356ad70d2 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -159,6 +159,18 @@ namespace HeavenStudio List entities = Beatmap.entities.Select(c => c.beat).ToList(); List tempoChanges = Beatmap.tempoChanges.Select(c => c.beat).ToList(); + if (currentTempoEvent < Beatmap.tempoChanges.Count && currentTempoEvent >= 0) + { + // Debug.Log("Checking Tempo Change at " + tempoChanges[currentTempoEvent] + ", current beat " + Conductor.instance.songPositionInBeats); + if (Conductor.instance.songPositionInBeats >= tempoChanges[currentTempoEvent]) + { + // Debug.Log("Tempo Change at " + Conductor.instance.songPositionInBeats + " of bpm " + Beatmap.tempoChanges[currentTempoEvent].tempo); + Conductor.instance.SetBpm(Beatmap.tempoChanges[currentTempoEvent].tempo); + Conductor.instance.timeSinceLastTempoChange = Time.time; + currentTempoEvent++; + } + } + if (currentEvent < Beatmap.entities.Count && currentEvent >= 0) { if (Conductor.instance.songPositionInBeats >= entities[currentEvent] /*&& SongPosLessThanClipLength(Conductor.instance.songPositionInBeats)*/) @@ -194,18 +206,6 @@ namespace HeavenStudio // currentEvent += gameManagerEntities.Count; } } - - if (currentTempoEvent < Beatmap.tempoChanges.Count && currentTempoEvent >= 0) - { - // Debug.Log("Checking Tempo Change at " + tempoChanges[currentTempoEvent] + ", current beat " + Conductor.instance.songPositionInBeats); - if (Conductor.instance.songPositionInBeats >= tempoChanges[currentTempoEvent]) - { - // Debug.Log("Tempo Change at " + Conductor.instance.songPositionInBeats + " of bpm " + Beatmap.tempoChanges[currentTempoEvent].tempo); - Conductor.instance.SetBpm(Beatmap.tempoChanges[currentTempoEvent].tempo); - Conductor.instance.timeSinceLastTempoChange = Time.time; - currentTempoEvent++; - } - } } public void ToggleInputs(bool inputs) diff --git a/Assets/Scripts/Games/CropStomp/CropStomp.cs b/Assets/Scripts/Games/CropStomp/CropStomp.cs index 11cda1633..72926f727 100644 --- a/Assets/Scripts/Games/CropStomp/CropStomp.cs +++ b/Assets/Scripts/Games/CropStomp/CropStomp.cs @@ -270,7 +270,7 @@ namespace HeavenStudio.Games public void StartMarching(float beat) { marchStartBeat = beat; - marchOffset = (marchStartBeat % 1) * Conductor.instance.secPerBeat / Conductor.instance.musicSource.pitch; + marchOffset = marchStartBeat % 1; currentMarchBeat = 0; stepCount = 0;