From c663781e5a11482786b5862e315bf867dd1b28c8 Mon Sep 17 00:00:00 2001 From: ThePurpleAnon <100617766+ThePurpleAnon@users.noreply.github.com> Date: Sat, 30 Dec 2023 22:41:37 -0600 Subject: [PATCH] Implemented functionality to "bop" + pitching sfx pretty much does what the title says. pitching for voicelines is automatic, and scales properly to tempo (based on 98 bpm) --- Assets/Scripts/Games/Manzai/Manzai.cs | 56 +++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/Games/Manzai/Manzai.cs b/Assets/Scripts/Games/Manzai/Manzai.cs index c3645df74..75be20d51 100644 --- a/Assets/Scripts/Games/Manzai/Manzai.cs +++ b/Assets/Scripts/Games/Manzai/Manzai.cs @@ -17,11 +17,15 @@ namespace HeavenStudio.Games.Loaders { new GameAction("bop", "Bop") { - function = delegate { Manzai.instance.Bop(); }, + function = delegate { + var e = eventCaller.currentEntity; + Manzai.instance.Bop(e.beat, e.length, e["who"], e["bop"], e["auto"]); + }, resizable = true, parameters = new List() { new Param("who", Manzai.WhoBops.Both, "Who Bops?", "Which bird bops"), + new Param("bop", true, "Enable Bopping", "Whether to bop to the beat or not"), new Param("auto", false, "Automatic?", "Whether to bop to the beat or not automatically"), } }, @@ -76,10 +80,12 @@ namespace HeavenStudio.Games [SerializeField] Animator VultureAnim; [SerializeField] Animator RavenAnim; + bool ravenBop = true; + bool vultureBop = true; + public enum WhoBops { - None, Kasuke, Kosuke, Both, @@ -139,28 +145,64 @@ namespace HeavenStudio.Games instance = this; } - public void Bop() + public override void OnLateBeatPulse(double beat) { - VultureAnim.DoScaledAnimationAsync("Bop", 0.5f); - RavenAnim.DoScaledAnimationAsync("Bop", 0.5f); + if (vultureBop) + VultureAnim.DoScaledAnimationAsync("Bop", 0.5f); + + if (ravenBop) + RavenAnim.DoScaledAnimationAsync("Bop", 0.5f); } + + public void Bop(double beat, float length, int whoBops, bool bop, bool autoBop) + { + ravenBop = (whoBops is (int)WhoBops.Kasuke or (int)WhoBops.Both) && autoBop; + vultureBop = (whoBops is (int)WhoBops.Kosuke or (int)WhoBops.Both) && autoBop; + + if (bop) + { + var actions = new List(); + for (int i = 0; i < length; i++) + { + if (whoBops is (int)WhoBops.Kasuke or (int)WhoBops.Both) actions.Add(new(beat + i, delegate { RavenAnim.DoScaledAnimationAsync("Bop", 0.5f); })); + if (whoBops is (int)WhoBops.Kosuke or (int)WhoBops.Both) actions.Add(new(beat + i, delegate { VultureAnim.DoScaledAnimationAsync("Bop", 0.5f); })); + } + BeatAction.New(this, actions); + } + } + public void DoPun(double beat) { - SoundByte.PlayOneShotGame("manzai/"+sfxDefs[0].sfx); + SoundByte.PlayOneShotGame("manzai/"+sfxDefs[0].sfx, pitch: Conductor.instance.songBpm/98); ScheduleInput(beat, 2.5f, InputAction_BasicPress, HaiJust, HaiMiss, Nothing); ScheduleInput(beat, 3.0f, InputAction_BasicPress, HaiJust, HaiMiss, Nothing); + BeatAction.New(instance, new List() + { + new BeatAction.Action(beat + 0.0f, delegate { VultureAnim.DoScaledAnimationAsync("Talk", 0.5f); }), + + new BeatAction.Action(beat + 0.5f, delegate { VultureAnim.DoScaledAnimationAsync("Talk", 0.5f); }), + + new BeatAction.Action(beat + 1.0f, delegate { VultureAnim.DoScaledAnimationAsync("Talk", 0.5f); }), + + new BeatAction.Action(beat + 1.5f, delegate { VultureAnim.DoScaledAnimationAsync("Talk", 0.5f); }), + }); } + public void HaiJust(PlayerActionEvent caller, float state) { - SoundByte.PlayOneShotGame("manzai/hai"); + SoundByte.PlayOneShotGame("manzai/hai", pitch: Conductor.instance.songBpm/98); SoundByte.PlayOneShotGame("manzai/haiAccent"); RavenAnim.DoScaledAnimationAsync("Talk", 0.5f); + VultureAnim.DoScaledAnimationAsync("Bop", 0.5f); } + public void HaiMiss(PlayerActionEvent caller) { SoundByte.PlayOneShotGame("manzai/hai"); RavenAnim.DoScaledAnimationAsync("Talk", 0.5f); + VultureAnim.DoScaledAnimationAsync("Bop", 0.5f); } + public void Nothing(PlayerActionEvent caller) {