Implemented inactive functions for all game count ins

Also made some changes to how SwitchGame(), OnGameSwitch, and the jukebox work.
This commit is contained in:
Slaith
2022-03-07 20:46:49 -08:00
parent 2d328229c9
commit fca105259c
11 changed files with 169 additions and 67 deletions

View File

@ -81,9 +81,9 @@ namespace RhythmHeavenMania.Util
return audioSource;
}
public static AudioSource PlayOneShotGame(string name, float beat = -1)
public static AudioSource PlayOneShotGame(string name, float beat = -1, bool forcePlay = false)
{
if (GameManager.instance.currentGame == name.Split('/')[0])
if (GameManager.instance.currentGame == name.Split('/')[0] || forcePlay)
{
return PlayOneShot($"games/{name}", beat);
}
@ -91,9 +91,9 @@ namespace RhythmHeavenMania.Util
return null;
}
public static AudioSource PlayOneShotScheduledGame(string name, double targetTime)
public static AudioSource PlayOneShotScheduledGame(string name, double targetTime, bool forcePlay = false)
{
if (GameManager.instance.currentGame == name.Split('/')[0])
if (GameManager.instance.currentGame == name.Split('/')[0] || forcePlay)
{
return PlayOneShotScheduled($"games/{name}", targetTime);
}

View File

@ -10,6 +10,7 @@ namespace RhythmHeavenMania.Util
private float startBeat;
private int index;
private bool game;
private bool forcePlay;
public List<Sound> sounds = new List<Sound>();
public class Sound
@ -25,7 +26,7 @@ namespace RhythmHeavenMania.Util
}
public static MultiSound Play(Sound[] snds, bool game = true)
public static MultiSound Play(Sound[] snds, bool game = true, bool forcePlay = false)
{
List<Sound> sounds = snds.ToList();
GameObject gameObj = new GameObject();
@ -33,6 +34,7 @@ namespace RhythmHeavenMania.Util
ms.sounds = sounds;
ms.startBeat = sounds[0].beat;
ms.game = game;
ms.forcePlay = forcePlay;
gameObj.name = "MultiSound";
GameManager.instance.SoundObjects.Add(gameObj);
@ -48,7 +50,7 @@ namespace RhythmHeavenMania.Util
if (songPositionInBeats >= sounds[i].beat && index == i)
{
if (game)
Jukebox.PlayOneShotGame(sounds[i].name);
Jukebox.PlayOneShotGame(sounds[i].name, forcePlay:forcePlay);
else
Jukebox.PlayOneShot(sounds[i].name);