mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-14 05:35:08 +00:00
Fork Lifter: Pea zoom sound lines up (mostly) independent of bpm
This commit is contained in:
parent
217849e666
commit
dfed5a879f
5 changed files with 72 additions and 4 deletions
BIN
Assets/Resources/Sfx/games/forkLifter/zoomFast.ogg
Normal file
BIN
Assets/Resources/Sfx/games/forkLifter/zoomFast.ogg
Normal file
Binary file not shown.
22
Assets/Resources/Sfx/games/forkLifter/zoomFast.ogg.meta
Normal file
22
Assets/Resources/Sfx/games/forkLifter/zoomFast.ogg.meta
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bae94bedea157574fa32d28216adaf01
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 6
|
||||||
|
defaultSettings:
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
preloadAudioData: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -19,7 +19,12 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
anim = GetComponent<Animator>();
|
anim = GetComponent<Animator>();
|
||||||
Jukebox.PlayOneShotGame("forkLifter/zoom");
|
|
||||||
|
// SCHEDULING zoom sound so it lines up with when it meets the fork.
|
||||||
|
var currentDspTime = AudioSettings.dspTime;
|
||||||
|
var zoomStartTime = currentDspTime + (double)(Conductor.instance.secPerBeat * 2) - 0.317;
|
||||||
|
Jukebox.PlayOneShotScheduledGame("forkLifter/zoomFast", (double)zoomStartTime);
|
||||||
|
|
||||||
GetComponentInChildren<SpriteRenderer>().sprite = ForkLifter.instance.peaSprites[type];
|
GetComponentInChildren<SpriteRenderer>().sprite = ForkLifter.instance.peaSprites[type];
|
||||||
|
|
||||||
for (int i = 0; i < transform.GetChild(0).childCount; i++)
|
for (int i = 0; i < transform.GetChild(0).childCount; i++)
|
||||||
|
|
|
@ -57,6 +57,26 @@ namespace RhythmHeavenMania.Util
|
||||||
GameManager.instance.SoundObjects.Add(oneShot);
|
GameManager.instance.SoundObjects.Add(oneShot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void PlayOneShotScheduled(string name, double targetTime)
|
||||||
|
{
|
||||||
|
GameObject oneShot = new GameObject("oneShotScheduled");
|
||||||
|
|
||||||
|
var audioSource = oneShot.AddComponent<AudioSource>();
|
||||||
|
audioSource.playOnAwake = false;
|
||||||
|
|
||||||
|
var snd = oneShot.AddComponent<Sound>();
|
||||||
|
|
||||||
|
var clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||||
|
audioSource.clip = clip;
|
||||||
|
snd.clip = clip;
|
||||||
|
|
||||||
|
snd.scheduled = true;
|
||||||
|
snd.scheduledTime = targetTime;
|
||||||
|
audioSource.PlayScheduled(targetTime);
|
||||||
|
|
||||||
|
GameManager.instance.SoundObjects.Add(oneShot);
|
||||||
|
}
|
||||||
|
|
||||||
public static void PlayOneShotGame(string name, float beat = -1)
|
public static void PlayOneShotGame(string name, float beat = -1)
|
||||||
{
|
{
|
||||||
if (GameManager.instance.currentGame == name.Split('/')[0])
|
if (GameManager.instance.currentGame == name.Split('/')[0])
|
||||||
|
@ -64,6 +84,14 @@ namespace RhythmHeavenMania.Util
|
||||||
PlayOneShot($"games/{name}", beat);
|
PlayOneShot($"games/{name}", beat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void PlayOneShotScheduledGame(string name, double targetTime)
|
||||||
|
{
|
||||||
|
if (GameManager.instance.currentGame == name.Split('/')[0])
|
||||||
|
{
|
||||||
|
PlayOneShotScheduled($"games/{name}", targetTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,6 +9,10 @@ namespace RhythmHeavenMania.Util
|
||||||
public AudioClip clip;
|
public AudioClip clip;
|
||||||
public float pitch = 1;
|
public float pitch = 1;
|
||||||
|
|
||||||
|
// For use with PlayOneShotScheduled
|
||||||
|
public bool scheduled;
|
||||||
|
public double scheduledTime;
|
||||||
|
|
||||||
private AudioSource audioSource;
|
private AudioSource audioSource;
|
||||||
|
|
||||||
private int pauseTimes = 0;
|
private int pauseTimes = 0;
|
||||||
|
@ -26,7 +30,7 @@ namespace RhythmHeavenMania.Util
|
||||||
audioSource.clip = clip;
|
audioSource.clip = clip;
|
||||||
audioSource.pitch = pitch;
|
audioSource.pitch = pitch;
|
||||||
|
|
||||||
if (beat == -1)
|
if (beat == -1 && !scheduled)
|
||||||
{
|
{
|
||||||
audioSource.PlayScheduled(Time.time);
|
audioSource.PlayScheduled(Time.time);
|
||||||
playInstant = true;
|
playInstant = true;
|
||||||
|
@ -39,12 +43,21 @@ namespace RhythmHeavenMania.Util
|
||||||
|
|
||||||
startTime = Conductor.instance.songPosition;
|
startTime = Conductor.instance.songPosition;
|
||||||
|
|
||||||
|
if (!scheduled)
|
||||||
StartCoroutine(NotRelyOnBeatSound());
|
StartCoroutine(NotRelyOnBeatSound());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (!playInstant)
|
if (scheduled)
|
||||||
|
{
|
||||||
|
if (AudioSettings.dspTime > scheduledTime)
|
||||||
|
{
|
||||||
|
StartCoroutine(NotRelyOnBeatSound());
|
||||||
|
playIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!playInstant)
|
||||||
{
|
{
|
||||||
if (Conductor.instance.songPositionInBeats > beat && playIndex < 1)
|
if (Conductor.instance.songPositionInBeats > beat && playIndex < 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue