mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 11:45:09 +00:00
Jukebox/Sound code cleanup
This commit is contained in:
parent
667a70b0ee
commit
9aeef1a9c3
4 changed files with 21 additions and 21 deletions
|
@ -190,7 +190,7 @@ namespace RhythmHeavenMania.Games.BuiltToScaleDS
|
||||||
var pianoPitch = Mathf.Pow(2f, (1f / 12f) * semiTones) *Conductor.instance.musicSource.pitch;
|
var pianoPitch = Mathf.Pow(2f, (1f / 12f) * semiTones) *Conductor.instance.musicSource.pitch;
|
||||||
var pianoSource = Jukebox.PlayOneShotGame("builtToScaleDS/Piano", -1, pianoPitch, 0.8f, true);
|
var pianoSource = Jukebox.PlayOneShotGame("builtToScaleDS/Piano", -1, pianoPitch, 0.8f, true);
|
||||||
|
|
||||||
Jukebox.SetLoopParams(pianoSource, beat + length, 0.1f);
|
pianoSource.SetLoopParams(beat + length, 0.1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,7 +19,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||||
public GameObject holder;
|
public GameObject holder;
|
||||||
public GameObject loop;
|
public GameObject loop;
|
||||||
|
|
||||||
private AudioSource pullSound;
|
private Sound pullSound;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace RhythmHeavenMania.Util
|
||||||
FindJukebox().GetComponent<AudioSource>().volume = volume;
|
FindJukebox().GetComponent<AudioSource>().volume = volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AudioSource PlayOneShot(string name, float beat = -1, float pitch = 1f, float volume = 1f, bool looping = false)
|
public static Sound PlayOneShot(string name, float beat = -1, float pitch = 1f, float volume = 1f, bool looping = false)
|
||||||
{
|
{
|
||||||
GameObject oneShot = new GameObject("oneShot");
|
GameObject oneShot = new GameObject("oneShot");
|
||||||
|
|
||||||
|
@ -59,10 +59,10 @@ namespace RhythmHeavenMania.Util
|
||||||
|
|
||||||
GameManager.instance.SoundObjects.Add(oneShot);
|
GameManager.instance.SoundObjects.Add(oneShot);
|
||||||
|
|
||||||
return audioSource;
|
return snd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AudioSource PlayOneShotScheduled(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false)
|
public static Sound PlayOneShotScheduled(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false)
|
||||||
{
|
{
|
||||||
GameObject oneShot = new GameObject("oneShotScheduled");
|
GameObject oneShot = new GameObject("oneShotScheduled");
|
||||||
|
|
||||||
|
@ -84,10 +84,10 @@ namespace RhythmHeavenMania.Util
|
||||||
|
|
||||||
GameManager.instance.SoundObjects.Add(oneShot);
|
GameManager.instance.SoundObjects.Add(oneShot);
|
||||||
|
|
||||||
return audioSource;
|
return snd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AudioSource PlayOneShotGame(string name, float beat = -1, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false)
|
public static Sound PlayOneShotGame(string name, float beat = -1, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false)
|
||||||
{
|
{
|
||||||
if (GameManager.instance.currentGame == name.Split('/')[0] || forcePlay)
|
if (GameManager.instance.currentGame == name.Split('/')[0] || forcePlay)
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ namespace RhythmHeavenMania.Util
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AudioSource PlayOneShotScheduledGame(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false)
|
public static Sound PlayOneShotScheduledGame(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false)
|
||||||
{
|
{
|
||||||
if (GameManager.instance.currentGame == name.Split('/')[0] || forcePlay)
|
if (GameManager.instance.currentGame == name.Split('/')[0] || forcePlay)
|
||||||
{
|
{
|
||||||
|
@ -107,24 +107,13 @@ namespace RhythmHeavenMania.Util
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loops play forever by default unless you set their params via this method.
|
public static void KillLoop(Sound source, float fadeTime)
|
||||||
public static void SetLoopParams(AudioSource source, float endBeat, float fadeTime)
|
|
||||||
{
|
|
||||||
if (source == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var snd = source.GetComponent<Sound>();
|
|
||||||
snd.loopEndBeat = endBeat;
|
|
||||||
snd.fadeTime = fadeTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void KillLoop(AudioSource source, float fadeTime)
|
|
||||||
{
|
{
|
||||||
// Safeguard against previously-destroyed sounds.
|
// Safeguard against previously-destroyed sounds.
|
||||||
if (source == null)
|
if (source == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
source.GetComponent<Sound>().KillLoop(fadeTime);
|
source.KillLoop(fadeTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,17 @@ namespace RhythmHeavenMania.Util
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetLoopParams(float endBeat, float fadeTime)
|
||||||
|
{
|
||||||
|
loopEndBeat = endBeat;
|
||||||
|
this.fadeTime = fadeTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
audioSource.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
public void Delete()
|
public void Delete()
|
||||||
{
|
{
|
||||||
GameManager.instance.SoundObjects.Remove(gameObject);
|
GameManager.instance.SoundObjects.Remove(gameObject);
|
||||||
|
|
Loading…
Reference in a new issue