diff --git a/Assets/Resources/Fonts/kurokane/FOT-KurokaneStd_Megamix_Modified-EB.otf b/Assets/Resources/Fonts/kurokane/FOT-KurokaneStd_Megamix_Modified-EB.otf index 291a4b88..49c0001b 100644 Binary files a/Assets/Resources/Fonts/kurokane/FOT-KurokaneStd_Megamix_Modified-EB.otf and b/Assets/Resources/Fonts/kurokane/FOT-KurokaneStd_Megamix_Modified-EB.otf differ diff --git a/Assets/Scripts/Conductor.cs b/Assets/Scripts/Conductor.cs index cf3b59f4..67a35f84 100644 --- a/Assets/Scripts/Conductor.cs +++ b/Assets/Scripts/Conductor.cs @@ -50,6 +50,7 @@ namespace HeavenStudio double dspSizeSeconds; double dspMargin = 128 / 44100.0; bool deferTimeKeeping = false; + public bool WaitingForDsp => deferTimeKeeping; // the dspTime we started at private double dspStart; @@ -163,6 +164,12 @@ namespace HeavenStudio GameManager.instance.SetCurrentEventToClosest(beat); } + public void PlaySetup(double beat) + { + deferTimeKeeping = true; + songPosBeat = beat; + } + public void Play(double beat) { if (isPlaying) return; @@ -220,7 +227,7 @@ namespace HeavenStudio startTime = DateTime.Now; absTimeAdjust = 0; - deferTimeKeeping = (musicSource.clip != null); + deferTimeKeeping = musicSource.clip != null; isPlaying = true; isPaused = false; diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 2070a11c..44eb5454 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -731,6 +731,7 @@ namespace HeavenStudio if (!paused) { + Conductor.instance.PlaySetup(beat); Minigame miniGame = null; if (currentGameO != null && currentGameO.TryGetComponent(out miniGame)) { diff --git a/Assets/Scripts/Games/FlipperFlop/FlipperFlop.cs b/Assets/Scripts/Games/FlipperFlop/FlipperFlop.cs index deb0e577..c0f80865 100644 --- a/Assets/Scripts/Games/FlipperFlop/FlipperFlop.cs +++ b/Assets/Scripts/Games/FlipperFlop/FlipperFlop.cs @@ -472,8 +472,6 @@ namespace HeavenStudio.Games } } - - if (thatsIt && i + 1 == length) { int noiseToPlay = (flopCount == 4) ? 2 : flopCount; @@ -613,7 +611,7 @@ namespace HeavenStudio.Games { for (int i = 0; i < uh; i++) { - int voiceLineIndex = i + 1; + int voiceLineIndex = 3 - uh + i + 1; string voiceLine = $"flipperFlop/uh{voiceLineIndex}"; string failVoiceLine = $"flipperFlop/uhfail{voiceLineIndex}"; diff --git a/Assets/Scripts/Games/TrickClass/TrickClass.cs b/Assets/Scripts/Games/TrickClass/TrickClass.cs index a73ea8a4..a962bff6 100644 --- a/Assets/Scripts/Games/TrickClass/TrickClass.cs +++ b/Assets/Scripts/Games/TrickClass/TrickClass.cs @@ -1,4 +1,3 @@ -using DG.Tweening; using NaughtyBezierCurves; using System; using System.Collections; @@ -169,7 +168,7 @@ namespace HeavenStudio.Games void OnDestroy() { - if (queuedInputs.Count > 0) queuedInputs.Clear(); + queuedInputs.Clear(); foreach (var evt in scheduledInputs) { evt.Disable(); @@ -194,14 +193,29 @@ namespace HeavenStudio.Games girlAnim.DoScaledAnimationAsync("Bop"); } - private void Update() + public override void OnPlay(double beat) { - var cond = Conductor.instance; - if (cond.isPlaying && !cond.isPaused) + queuedInputs.Clear(); + } + + public override void OnGameSwitch(double beat) + { + if (!Conductor.instance.isPlaying) return; + if (queuedInputs.Count > 0) { - if (queuedInputs.Count > 0) + foreach (var input in queuedInputs) { - foreach (var input in queuedInputs) + if (input.type is (int)TrickObjType.Blast) + { + BeatAction.New(instance, new List() + { + new BeatAction.Action(input.beat, delegate + { + instance.DoBlast(input.beat); + }) + }); + } + else { BeatAction.New(instance, new List() { @@ -216,10 +230,13 @@ namespace HeavenStudio.Games }) }); } - queuedInputs.Clear(); } } + queuedInputs.Clear(); + } + private void Update() + { if (PlayerInput.GetIsAction(InputAction_TouchPressing) && (!playerReady) && (playerCanDodge <= Conductor.instance.songPositionInBeatsAsDouble)) { playerAnim.DoScaledAnimationAsync("Prepare"); @@ -392,11 +409,6 @@ namespace HeavenStudio.Games { girlAnim.DoScaledAnimationAsync("Charge1"); }), - new BeatAction.Action(beat + 2, delegate - { - //test - // girlAnim.DoScaledAnimationAsync("BlastDodged", 0.5f); - }), new BeatAction.Action(beat + 4, delegate { girlBopEnable = true; diff --git a/Assets/Scripts/Util/MultiSound.cs b/Assets/Scripts/Util/MultiSound.cs index 19eb35cd..85d2ab17 100644 --- a/Assets/Scripts/Util/MultiSound.cs +++ b/Assets/Scripts/Util/MultiSound.cs @@ -2,6 +2,8 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; +using Cysharp.Threading.Tasks; +using Cysharp.Threading.Tasks.Triggers; namespace HeavenStudio.Util { @@ -10,6 +12,7 @@ namespace HeavenStudio.Util private double startBeat; private bool game; private bool forcePlay; + private bool commited; public List sounds = new List(); public List playingSounds = new List(); @@ -36,14 +39,33 @@ namespace HeavenStudio.Util public static MultiSound Play(Sound[] snds, bool game = true, bool forcePlay = false) { + if (Conductor.instance == null) return null; + List sounds = snds.ToList(); GameObject go = new GameObject("MultiSound"); MultiSound ms = go.AddComponent(); + ms.sounds = sounds; ms.startBeat = sounds[0].beat; ms.game = game; ms.forcePlay = forcePlay; + ms.commited = false; + if (Conductor.instance.WaitingForDsp) + { + Debug.Log("Multisound waiting for DSP, deferring play"); + ms.PlayDeferred().Forget(); + } + else + { + ms.CommitPlay(); + } + + return ms; + } + + void CommitPlay() + { for (int i = 0; i < sounds.Count; i++) { Util.Sound s; @@ -51,14 +73,21 @@ namespace HeavenStudio.Util s = SoundByte.PlayOneShotGame(sounds[i].name, sounds[i].beat, sounds[i].pitch, sounds[i].volume, sounds[i].looping, forcePlay, sounds[i].offset); else s = SoundByte.PlayOneShot(sounds[i].name, sounds[i].beat, sounds[i].pitch, sounds[i].volume, sounds[i].looping, null, sounds[i].offset); - ms.playingSounds.Add(s); + playingSounds.Add(s); } + commited = true; + } - return ms; + async UniTaskVoid PlayDeferred() + { + await UniTask.WaitUntil(() => !Conductor.instance.WaitingForDsp, PlayerLoopTiming.LastUpdate); + Debug.Log("Multisound DSP ready, playing"); + CommitPlay(); } private void Update() { + if (!commited) return; foreach (Util.Sound sound in playingSounds) { if (sound == null) continue;