From d770266d8107e88f98311b824fce24e7222cb993 Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:03:08 +0200 Subject: [PATCH] Rhythm tweezers pass turn now works like working dough --- .../Games/RhythmTweezers/RhythmTweezers.cs | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs b/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs index 86042325..6f710ec0 100644 --- a/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs +++ b/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs @@ -37,8 +37,7 @@ namespace HeavenStudio.Games.Loaders }, new GameAction("passTurn", "Pass Turn") { - function = delegate { var e = eventCaller.currentEntity; RhythmTweezers.instance.PassTurn(e.beat); }, - preFunction = delegate { var e = eventCaller.currentEntity; RhythmTweezers.PrePassTurn(e.beat, e.length); } + preFunction = delegate { var e = eventCaller.currentEntity; RhythmTweezers.PrePassTurn(e.beat); }, }, new GameAction("next vegetable", "Swap Vegetable") { @@ -352,24 +351,27 @@ namespace HeavenStudio.Games { if (crHandlerInstance.queuedEvents.Count > 0) { - hairsLeft = crHandlerInstance.queuedEvents.Count; - foreach (var crEvent in crHandlerInstance.queuedEvents) - { - if (crEvent.tag == "Hair") - { - Hair hairToInput = spawnedHairs.Find(x => x.createBeat == crEvent.beat); - hairToInput.StartInput(beat + 1, crEvent.relativeBeat); - } - else if (crEvent.tag == "Long") - { - LongHair hairToInput = spawnedLongs.Find(x => x.createBeat == crEvent.beat); - hairToInput.StartInput(beat + 1, crEvent.relativeBeat); - } - } - crHandlerInstance.queuedEvents.Clear(); BeatAction.New(instance.gameObject, new List() { - new BeatAction.Action(beat + 1, delegate + new BeatAction.Action(beat - 1, delegate + { + hairsLeft = crHandlerInstance.queuedEvents.Count; + foreach (var crEvent in crHandlerInstance.queuedEvents) + { + if (crEvent.tag == "Hair") + { + Hair hairToInput = spawnedHairs.Find(x => x.createBeat == crEvent.beat); + hairToInput.StartInput(beat, crEvent.relativeBeat); + } + else if (crEvent.tag == "Long") + { + LongHair hairToInput = spawnedLongs.Find(x => x.createBeat == crEvent.beat); + hairToInput.StartInput(beat, crEvent.relativeBeat); + } + } + crHandlerInstance.queuedEvents.Clear(); + }), + new BeatAction.Action(beat, delegate { if (crHandlerInstance.queuedEvents.Count > 0) { @@ -379,12 +381,12 @@ namespace HeavenStudio.Games if (crEvent.tag == "Hair") { Hair hairToInput = spawnedHairs.Find(x => x.createBeat == crEvent.beat); - hairToInput.StartInput(beat + 1, crEvent.relativeBeat); + hairToInput.StartInput(beat, crEvent.relativeBeat); } else if (crEvent.tag == "Long") { LongHair hairToInput = spawnedLongs.Find(x => x.createBeat == crEvent.beat); - hairToInput.StartInput(beat + 1, crEvent.relativeBeat); + hairToInput.StartInput(beat, crEvent.relativeBeat); } } crHandlerInstance.queuedEvents.Clear(); @@ -394,22 +396,23 @@ namespace HeavenStudio.Games } } - public static void PrePassTurn(double beat, float length) + public static void PrePassTurn(double beat) { if (GameManager.instance.currentGame == "rhythmTweezers") { - instance.SetPassTurnValues(beat + length); + instance.SetPassTurnValues(beat); + instance.PassTurn(beat); } else { - passedTurns.Add(beat + length); + passedTurns.Add(beat); } } private void SetPassTurnValues(double startBeat) { if (crHandlerInstance.intervalLength <= 0) return; - passTurnBeat = startBeat - 1f; + passTurnBeat = startBeat - 1; passTurnEndBeat = startBeat + crHandlerInstance.intervalLength; } @@ -512,6 +515,7 @@ namespace HeavenStudio.Games foreach (var turn in passedTurns) { SetPassTurnValues(turn); + PassTurn(turn); } passedTurns.Clear(); }