From a8403ff07840d0ef3ee540d02670cb65ec08b269 Mon Sep 17 00:00:00 2001 From: DPS2004 <10176105+DPS2004@users.noreply.github.com> Date: Sat, 20 Aug 2022 14:45:54 -0400 Subject: [PATCH] cowbell no longer drifts out of sync --- Assets/Scripts/Games/Tunnel/Tunnel.cs | 42 ++++++++++++--------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/Assets/Scripts/Games/Tunnel/Tunnel.cs b/Assets/Scripts/Games/Tunnel/Tunnel.cs index 54c7914b..802cd3fa 100644 --- a/Assets/Scripts/Games/Tunnel/Tunnel.cs +++ b/Assets/Scripts/Games/Tunnel/Tunnel.cs @@ -68,10 +68,7 @@ namespace HeavenStudio.Games public BezierCurve3D handCurve; - - public PlayerActionEvent cowbell; - - + public GameEvent cowbell = new GameEvent(); public int driverState; @@ -90,13 +87,21 @@ namespace HeavenStudio.Games { driverState = 0; handStart = -1f; - - - cowbell = null; } private void Update() { + + var cond = Conductor.instance; + if (cond.ReportBeat(ref cowbell.lastReportedBeat, cowbell.startBeat % 1)) + { + if (cond.songPositionInBeats >= cowbell.startBeat && cond.songPositionInBeats < cowbell.startBeat + cowbell.length) + { + ScheduleInput(cond.songPositionInBeats, 1, InputType.STANDARD_DOWN, CowbellSuccess, CowbellMiss, CowbellEmpty); + } + } + + if (PlayerInput.Pressed() && !IsExpectingInputNow()) { HitCowbell(); @@ -132,25 +137,16 @@ namespace HeavenStudio.Games { started = true; + cowbell.length = length; + cowbell.startBeat = beat; - for (int i = 1; i <= length; i++) - { - ScheduleInput(beat, i, InputType.STANDARD_DOWN, CowbellSuccess, CowbellMiss, CowbellEmpty); - } - //if (coin != null) return; + //for (int i = 1; i <= length; i++) + //{ + //ScheduleInput(beat, i, InputType.STANDARD_DOWN, CowbellSuccess, CowbellMiss, CowbellEmpty); + //} - //Play sound and animations - - //handAnimator.Play("Throw", 0, 0); - //Game state says the hand is throwing the coin - //isThrowing = true; - - //this.audienceReacting = audienceReacting; - - //coin = ScheduleInput(beat, 6f, InputType.STANDARD_DOWN, CatchSuccess, CatchMiss, CatchEmpty); - //cowbell = ScheduleInput(beat, 0f, InputType.STANDARD_DOWN, CowbellSuccess, CowbellMiss, CowbellEmpty); - //coin.perfectOnly = true; + } public void CowbellSuccess(PlayerActionEvent caller, float state)