mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 13:27:41 +02:00
Improved Sound Loading (#688)
* basic audio preloading could this operation be timesliced even more? * note * load sounds in subfolders from their ABs properly fix sound names that would conflict from this change * also grab from cache in this method * fix ringside's assetbundle * several AB sfx fixes air rally catchy tune coin toss karate man lockstep marching orders mr upbeat samurai slice gold tambourine tram&pauline trick on the class working dough * fix flipper flop assetbundle * fix weird issue with pause menu arrow
This commit is contained in:
@ -179,7 +179,6 @@ namespace HeavenStudio
|
||||
{
|
||||
AudioConfiguration config = AudioSettings.GetConfiguration();
|
||||
dspSizeSeconds = config.dspBufferSize / (double)config.sampleRate;
|
||||
Debug.Log($"dsp size: {dspSizeSeconds}");
|
||||
dspMargin = 2 * dspSizeSeconds;
|
||||
|
||||
SetMinigameVolume(1f);
|
||||
@ -210,7 +209,6 @@ namespace HeavenStudio
|
||||
}
|
||||
musicSource.PlayScheduled(musicScheduledTime);
|
||||
musicSource.pitch = timelinePitch;
|
||||
Debug.Log($"playback scheduled for dsptime {dspStart}");
|
||||
}
|
||||
|
||||
songPosBeat = beat;
|
||||
@ -234,7 +232,7 @@ namespace HeavenStudio
|
||||
if (deferTimeKeeping && dsp >= dspStart - dspSizeSeconds)
|
||||
{
|
||||
deferTimeKeeping = false;
|
||||
Debug.Log($"dsptime: {dsp}, deferred timekeeping for {DateTime.Now - startTime} seconds (delta dsp {dsp - dspStart})");
|
||||
// Debug.Log($"dsptime: {dsp}, deferred timekeeping for {DateTime.Now - startTime} seconds (delta dsp {dsp - dspStart})");
|
||||
startTime += TimeSpan.FromSeconds(dsp - dspStart);
|
||||
absTimeAdjust = 0;
|
||||
dspStart = dsp;
|
||||
|
@ -159,6 +159,7 @@ namespace HeavenStudio
|
||||
GoForAPerfect.instance.Disable();
|
||||
/////
|
||||
|
||||
SoundByte.BasicCheck();
|
||||
SoundObjects = new ObjectPool<Sound>(CreatePooledSound, OnTakePooledSound, OnReturnPooledSound, OnDestroyPooledSound, true, SoundPoolSizeMin, SoundPoolSizeMax);
|
||||
|
||||
|
||||
@ -177,15 +178,18 @@ namespace HeavenStudio
|
||||
Conductor.instance.SetVolume(Beatmap.VolumeChanges[0]["volume"]);
|
||||
Conductor.instance.firstBeatOffset = Beatmap.data.offset;
|
||||
|
||||
if (Beatmap.Entities.Count >= 1)
|
||||
if (!preLoaded)
|
||||
{
|
||||
string game = Beatmap.Entities[0].datamodel.Split(0);
|
||||
SetCurrentGame(game);
|
||||
StartCoroutine(WaitAndSetGame(game));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetGame("noGame");
|
||||
if (Beatmap.Entities.Count >= 1)
|
||||
{
|
||||
string game = Beatmap.Entities[0].datamodel.Split(0);
|
||||
SetCurrentGame(game);
|
||||
StartCoroutine(WaitAndSetGame(game));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetGame("noGame");
|
||||
}
|
||||
}
|
||||
|
||||
if (playMode)
|
||||
@ -303,22 +307,10 @@ namespace HeavenStudio
|
||||
{
|
||||
Stop(0);
|
||||
}
|
||||
SetCurrentEventToClosest(0);
|
||||
|
||||
if (Beatmap.Entities.Count >= 1)
|
||||
{
|
||||
string game = Beatmap.Entities[0].datamodel.Split(0);
|
||||
SetCurrentGame(game);
|
||||
StartCoroutine(WaitAndSetGame(game));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetGame("noGame");
|
||||
}
|
||||
SetCurrentEventToClosest(0, true);
|
||||
|
||||
if (editor)
|
||||
{
|
||||
Debug.Log(Beatmap.data.riqOrigin);
|
||||
if (Beatmap.data.riqOrigin != "HeavenStudio")
|
||||
{
|
||||
string origin = Beatmap.data.riqOrigin?.DisplayName() ?? "Unknown Origin";
|
||||
@ -384,7 +376,7 @@ namespace HeavenStudio
|
||||
inf = GetGameInfo(gameName);
|
||||
if (inf != null && !(inf.inferred || inf.fxOnly))
|
||||
{
|
||||
if (inf.usesAssetBundle && !inf.AssetsLoaded)
|
||||
if (inf.usesAssetBundle && !(inf.AssetsLoaded || inf.AlreadyLoading))
|
||||
{
|
||||
gamesToPreload.Add(inf);
|
||||
Debug.Log($"ASYNC loading assetbundles for game {gameName}");
|
||||
@ -709,10 +701,7 @@ namespace HeavenStudio
|
||||
{
|
||||
yield return new WaitForSeconds(delay);
|
||||
}
|
||||
}
|
||||
|
||||
if (!paused)
|
||||
{
|
||||
Conductor.instance.PlaySetup(beat);
|
||||
Minigame miniGame = null;
|
||||
if (minigameObj != null && minigameObj.TryGetComponent<Minigame>(out miniGame))
|
||||
@ -813,6 +802,10 @@ namespace HeavenStudio
|
||||
|
||||
private IEnumerator WaitReadyAndPlayCo(double beat, float delay = 1f, bool discord = true)
|
||||
{
|
||||
SoundByte.UnloadAudioClips();
|
||||
SoundByte.PreloadAudioClipAsync("skillStar");
|
||||
SoundByte.PreloadAudioClipAsync("perfectMiss");
|
||||
|
||||
WaitUntil yieldOverlays = new WaitUntil(() => OverlaysManager.OverlaysReady);
|
||||
WaitUntil yieldBeatmap = new WaitUntil(() => Beatmap != null && BeatmapEntities() > 0);
|
||||
WaitUntil yieldAudio = new WaitUntil(() => AudioLoadDone || (ChartLoadError && !GlobalGameManager.IsShowingDialog));
|
||||
@ -856,7 +849,7 @@ namespace HeavenStudio
|
||||
{
|
||||
Debug.Log("Killing all sounds");
|
||||
SoundObjects.Clear();
|
||||
Util.SoundByte.KillOneShots();
|
||||
SoundByte.KillOneShots();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -945,7 +938,7 @@ namespace HeavenStudio
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void SetCurrentEventToClosest(double beat)
|
||||
public void SetCurrentEventToClosest(double beat, bool canPreload = false)
|
||||
{
|
||||
SortEventsList();
|
||||
onBeatChanged?.Invoke(beat);
|
||||
@ -991,7 +984,15 @@ namespace HeavenStudio
|
||||
|
||||
if (!GetGameInfo(newGame).fxOnly)
|
||||
{
|
||||
SetGame(newGame);
|
||||
if (canPreload)
|
||||
{
|
||||
StartCoroutine(WaitAndSetGame(newGame));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetGame(newGame);
|
||||
}
|
||||
SetCurrentGame(newGame);
|
||||
}
|
||||
|
||||
List<RiqEntity> allEnds = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "end" });
|
||||
@ -1129,19 +1130,27 @@ namespace HeavenStudio
|
||||
public void DestroyGame()
|
||||
{
|
||||
cachedGamePrefabs.Clear();
|
||||
SoundByte.UnloadAudioClips();
|
||||
SetGame("noGame");
|
||||
}
|
||||
|
||||
private IEnumerator WaitAndSetGame(string game, bool useMinigameColor = true)
|
||||
{
|
||||
var inf = GetGameInfo(game);
|
||||
if (inf != null && inf.usesAssetBundle && !inf.AssetsLoaded)
|
||||
if (inf != null && inf.usesAssetBundle)
|
||||
{
|
||||
Debug.Log($"ASYNC loading assetbundles for game {game}");
|
||||
inf.LoadAssetsAsync().Forget();
|
||||
if (!(inf.AssetsLoaded || inf.AlreadyLoading))
|
||||
{
|
||||
Debug.Log($"ASYNC loading assetbundles for game {game}");
|
||||
inf.LoadAssetsAsync().Forget();
|
||||
}
|
||||
yield return new WaitUntil(() => inf.AssetsLoaded);
|
||||
SetGame(game, useMinigameColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetGame(game, useMinigameColor);
|
||||
}
|
||||
SetGame(game, useMinigameColor);
|
||||
}
|
||||
|
||||
public void PreloadGameSequences(string game)
|
||||
|
@ -818,10 +818,10 @@ namespace HeavenStudio.Games
|
||||
float realLength = length / 4;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("airRally/countIn1" + GetDistanceStringAtBeat(beat, true), beat, 1, 1, false, countInOffsets[0]),
|
||||
new MultiSound.Sound("airRally/countIn2" + GetDistanceStringAtBeat(beat + (1 * realLength), true), beat + (1 * realLength), 1, 1, false, countInOffsets[1]),
|
||||
new MultiSound.Sound("airRally/countIn3" + GetDistanceStringAtBeat(beat + (2 * realLength), true), beat + (2 * realLength), 1, 1, false, countInOffsets[2]),
|
||||
new MultiSound.Sound("airRally/countIn4" + GetDistanceStringAtBeat(beat + (3 * realLength), true), beat + (3 * realLength), 1, 1, false, countInOffsets[3]),
|
||||
new MultiSound.Sound("airRally/en/countIn1" + GetDistanceStringAtBeat(beat, true), beat, 1, 1, false, countInOffsets[0]),
|
||||
new MultiSound.Sound("airRally/en/countIn2" + GetDistanceStringAtBeat(beat + (1 * realLength), true), beat + (1 * realLength), 1, 1, false, countInOffsets[1]),
|
||||
new MultiSound.Sound("airRally/en/countIn3" + GetDistanceStringAtBeat(beat + (2 * realLength), true), beat + (2 * realLength), 1, 1, false, countInOffsets[2]),
|
||||
new MultiSound.Sound("airRally/en/countIn4" + GetDistanceStringAtBeat(beat + (3 * realLength), true), beat + (3 * realLength), 1, 1, false, countInOffsets[3]),
|
||||
}, forcePlay: true);
|
||||
}
|
||||
|
||||
@ -898,12 +898,12 @@ namespace HeavenStudio.Games
|
||||
float realLength = length / 8;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("airRally/countIn1" + GetDistanceStringAtBeat(beat, true), beat, 1, 1, false, countInOffsets[0]),
|
||||
new MultiSound.Sound("airRally/countIn2" + GetDistanceStringAtBeat(beat + (2 * realLength), true), beat + (2 * realLength), 1, 1, false, countInOffsets[1]),
|
||||
new MultiSound.Sound("airRally/countIn1" + GetDistanceStringAtBeat(beat + (4 * realLength), true), beat + (4 * realLength), 1, 1, false, countInOffsets[0]),
|
||||
new MultiSound.Sound("airRally/countIn2" + GetDistanceStringAtBeat(beat + (5 * realLength), true), beat + (5 * realLength), 1, 1, false, countInOffsets[1]),
|
||||
new MultiSound.Sound("airRally/countIn3" + GetDistanceStringAtBeat(beat + (6 * realLength), true), beat + (6 * realLength), 1, 1, false, countInOffsets[2]),
|
||||
new MultiSound.Sound("airRally/countIn4" + GetDistanceStringAtBeat(beat + (7 * realLength), true), beat + (7 * realLength), 1, 1, false, countInOffsets[3]),
|
||||
new MultiSound.Sound("airRally/en/countIn1" + GetDistanceStringAtBeat(beat, true), beat, 1, 1, false, countInOffsets[0]),
|
||||
new MultiSound.Sound("airRally/en/countIn2" + GetDistanceStringAtBeat(beat + (2 * realLength), true), beat + (2 * realLength), 1, 1, false, countInOffsets[1]),
|
||||
new MultiSound.Sound("airRally/en/countIn1" + GetDistanceStringAtBeat(beat + (4 * realLength), true), beat + (4 * realLength), 1, 1, false, countInOffsets[0]),
|
||||
new MultiSound.Sound("airRally/en/countIn2" + GetDistanceStringAtBeat(beat + (5 * realLength), true), beat + (5 * realLength), 1, 1, false, countInOffsets[1]),
|
||||
new MultiSound.Sound("airRally/en/countIn3" + GetDistanceStringAtBeat(beat + (6 * realLength), true), beat + (6 * realLength), 1, 1, false, countInOffsets[2]),
|
||||
new MultiSound.Sound("airRally/en/countIn4" + GetDistanceStringAtBeat(beat + (7 * realLength), true), beat + (7 * realLength), 1, 1, false, countInOffsets[3]),
|
||||
}, forcePlay: true);
|
||||
}
|
||||
|
||||
@ -934,25 +934,25 @@ namespace HeavenStudio.Games
|
||||
case DistanceSound.close:
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound($"airRally/countIn{type + 1}", beat, 1, 1, false, offset),
|
||||
new MultiSound.Sound($"airRally/en/countIn{type + 1}", beat, 1, 1, false, offset),
|
||||
}, forcePlay: true);
|
||||
break;
|
||||
case DistanceSound.far:
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound($"airRally/countIn{type + 1}Far", beat, 1, 1, false, offset),
|
||||
new MultiSound.Sound($"airRally/en/countIn{type + 1}Far", beat, 1, 1, false, offset),
|
||||
}, forcePlay: true);
|
||||
break;
|
||||
case DistanceSound.farther:
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound($"airRally/countIn{type + 1}Farther", beat, 1, 1, false, offset),
|
||||
new MultiSound.Sound($"airRally/en/countIn{type + 1}Farther", beat, 1, 1, false, offset),
|
||||
}, forcePlay: true);
|
||||
break;
|
||||
case DistanceSound.farthest:
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound($"airRally/countIn{type + 1}Farthest", beat, 1, 1, false, offset),
|
||||
new MultiSound.Sound($"airRally/en/countIn{type + 1}Farthest", beat, 1, 1, false, offset),
|
||||
}, forcePlay: true);
|
||||
break;
|
||||
}
|
||||
@ -1230,7 +1230,7 @@ namespace HeavenStudio.Games
|
||||
string distanceString = GetDistanceStringAtBeat(beat);
|
||||
if (distanceString != "Close") SoundByte.PlayOneShotGame("airRally/whooshForth_" + distanceString, beat + 1, 1, 1, false, false, whooshOffsetsRally[(int)DistanceAtBeat(beat)]);
|
||||
if (!(silent || isBaBumBeat) || (isCatch && !silent))
|
||||
SoundByte.PlayOneShotGame("airRally/nya_" + distanceString, beat, 1, 1, false, false, nyaOffsets[(int)DistanceAtBeat(beat)]);
|
||||
SoundByte.PlayOneShotGame("airRally/en/nya_" + distanceString, beat, 1, 1, false, false, nyaOffsets[(int)DistanceAtBeat(beat)]);
|
||||
|
||||
BeatAction.New(this, new List<BeatAction.Action>()
|
||||
{
|
||||
@ -1301,10 +1301,10 @@ namespace HeavenStudio.Games
|
||||
|
||||
sounds.AddRange(new List<MultiSound.Sound>()
|
||||
{
|
||||
new MultiSound.Sound("airRally/baBumBumBum_" + GetDistanceStringAlt(beat - 0.5) + "1", beat - 0.5, offset: GetBaBumOffset(beat - 0.5, 0)),
|
||||
new MultiSound.Sound("airRally/baBumBumBum_" + GetDistanceStringAlt(beat) + "2", beat, offset: GetBaBumOffset(beat, 0)),
|
||||
new MultiSound.Sound("airRally/baBumBumBum_" + GetDistanceStringAlt(beat + 1f) + "3", beat + 1, offset: GetBaBumOffset(beat + 1, 0)),
|
||||
new MultiSound.Sound("airRally/baBumBumBum_" + GetDistanceStringAlt(beat + 2f) + "4", beat + 2, offset: GetBaBumOffset(beat + 2, 0)),
|
||||
new MultiSound.Sound("airRally/en/baBumBumBum_" + GetDistanceStringAlt(beat - 0.5) + "1", beat - 0.5, offset: GetBaBumOffset(beat - 0.5, 0)),
|
||||
new MultiSound.Sound("airRally/en/baBumBumBum_" + GetDistanceStringAlt(beat) + "2", beat, offset: GetBaBumOffset(beat, 0)),
|
||||
new MultiSound.Sound("airRally/en/baBumBumBum_" + GetDistanceStringAlt(beat + 1f) + "3", beat + 1, offset: GetBaBumOffset(beat + 1, 0)),
|
||||
new MultiSound.Sound("airRally/en/baBumBumBum_" + GetDistanceStringAlt(beat + 2f) + "4", beat + 2, offset: GetBaBumOffset(beat + 2, 0)),
|
||||
|
||||
});
|
||||
|
||||
@ -1343,9 +1343,9 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
sounds.AddRange(new List<MultiSound.Sound>()
|
||||
{
|
||||
new MultiSound.Sound("airRally/countIn2" + GetDistanceStringAtBeat(beat + 3f, true), beat + 3, 1, 1, false, countInOffsets[1]),
|
||||
new MultiSound.Sound("airRally/countIn3" + GetDistanceStringAtBeat(beat + 4f, true), beat + 4, 1, 1, false, countInOffsets[2]),
|
||||
new MultiSound.Sound("airRally/countIn4" + GetDistanceStringAtBeat(beat + 5f, true), beat + 5, 1, 1, false, countInOffsets[3]),
|
||||
new MultiSound.Sound("airRally/en/countIn2" + GetDistanceStringAtBeat(beat + 3f, true), beat + 3, 1, 1, false, countInOffsets[1]),
|
||||
new MultiSound.Sound("airRally/en/countIn3" + GetDistanceStringAtBeat(beat + 4f, true), beat + 4, 1, 1, false, countInOffsets[2]),
|
||||
new MultiSound.Sound("airRally/en/countIn4" + GetDistanceStringAtBeat(beat + 5f, true), beat + 5, 1, 1, false, countInOffsets[3]),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ namespace HeavenStudio.Games
|
||||
wrestlerAnim.Play($"Pose{randomPose}", 0, 0);
|
||||
if (canDoMissExpression()) reporterAnim.Play("FlinchReporter", 0, 0);
|
||||
if (canDoMissExpression()) reporterHeadAnim.Play("Flinch", 0, 0);
|
||||
SoundByte.PlayOneShotGame($"ringside/new/badpose_{UnityEngine.Random.Range(1, 7)}");
|
||||
SoundByte.PlayOneShotGame($"ringside/badpose_{UnityEngine.Random.Range(1, 7)}");
|
||||
wrestlerTransform.localScale = new Vector3(1.1f, 1.1f, 1f);
|
||||
BeatAction.New(instance, new List<BeatAction.Action>()
|
||||
{
|
||||
@ -386,12 +386,12 @@ namespace HeavenStudio.Games
|
||||
List<MultiSound.Sound> qSounds = new List<MultiSound.Sound>();
|
||||
if (alt)
|
||||
{
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/new/wubdub_var{currentQuestion}_1", beat, 1, 1, false, 0.015));
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/en/wubdub_var{currentQuestion}_1", beat, 1, 1, false, 0.015));
|
||||
}
|
||||
else
|
||||
{
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/new/wubdub_var{currentQuestion}_1", beat, 1, 1, false, 0.015));
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/new/wubdub_var{currentQuestion}_2", beat + 0.25f, 1, 1, false, 0.002));
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/en/wubdub_var{currentQuestion}_1", beat, 1, 1, false, 0.015));
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/en/wubdub_var{currentQuestion}_2", beat + 0.25f, 1, 1, false, 0.002));
|
||||
}
|
||||
float extend = length - 3f;
|
||||
int totalExtend = 0;
|
||||
@ -399,10 +399,10 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
for (int i = 0; i < extend; i++)
|
||||
{
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/new/wubdub_var{currentQuestion}_3", beat + i + 0.5f, 1, 1, false, 0.003 ));
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/new/wubdub_var{currentQuestion}_4", beat + i + 0.75f, 1, 1, false, 0 ));
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/new/wubdub_var{currentQuestion}_5", beat + i + 1f, 1, 1, false, 0 ));
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/new/wubdub_var{currentQuestion}_6", beat + i + 1.25f, 1, 1, false, 0 ));
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/en/wubdub_var{currentQuestion}_3", beat + i + 0.5f, 1, 1, false, 0.003 ));
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/en/wubdub_var{currentQuestion}_4", beat + i + 0.75f, 1, 1, false, 0 ));
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/en/wubdub_var{currentQuestion}_5", beat + i + 1f, 1, 1, false, 0 ));
|
||||
qSounds.Add(new MultiSound.Sound($"ringside/en/wubdub_var{currentQuestion}_6", beat + i + 1.25f, 1, 1, false, 0 ));
|
||||
totalExtend++;
|
||||
}
|
||||
}
|
||||
@ -431,12 +431,12 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound($"ringside/new/wubdub_var{currentQuestion}_7", beat + 0.5f, 1, 1, false, 0.025),
|
||||
new MultiSound.Sound($"ringside/new/wubdub_konk_1", beat + 0.5f, 1, 1, false, 0),
|
||||
new MultiSound.Sound($"ringside/new/wubdub_konk_2", beat + 0.75f, 1, 1, false, 0),
|
||||
new MultiSound.Sound($"ringside/new/wubdub_var{currentQuestion}_8", beat + 1f, 1, 1, false, 0.018),
|
||||
new MultiSound.Sound($"ringside/new/wubdub_konk_3", beat + 1f, 1, 1, false, 0),
|
||||
new MultiSound.Sound($"ringside/new/mic_swoosh", beat + 1f, 1, 1, false, 0),
|
||||
new MultiSound.Sound($"ringside/en/wubdub_var{currentQuestion}_7", beat + 0.5f, 1, 1, false, 0.025),
|
||||
new MultiSound.Sound($"ringside/wubdub_konk_1", beat + 0.5f, 1, 1, false, 0),
|
||||
new MultiSound.Sound($"ringside/wubdub_konk_2", beat + 0.75f, 1, 1, false, 0),
|
||||
new MultiSound.Sound($"ringside/en/wubdub_var{currentQuestion}_8", beat + 1f, 1, 1, false, 0.018),
|
||||
new MultiSound.Sound($"ringside/wubdub_konk_3", beat + 1f, 1, 1, false, 0),
|
||||
new MultiSound.Sound($"ringside/mic_swoosh", beat + 1f, 1, 1, false, 0),
|
||||
}, forcePlay: true);
|
||||
ScheduleInput(beat, 2f, InputAction_BasicPress, JustQuestion, Miss, Nothing);
|
||||
BeatAction.New(instance, new List<BeatAction.Action>()
|
||||
@ -457,12 +457,12 @@ namespace HeavenStudio.Games
|
||||
if (currentQuestion == (int)QuestionVariant.Third) youBeat = 0.027f;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound($"ringside/new/bigguy_var{currentQuestion}_1", beat, 1, 1, false, youBeat),
|
||||
new MultiSound.Sound($"ringside/new/bigguy_var{currentQuestion}_2", beat + 0.75f, 1, 1, false, youBeat),
|
||||
new MultiSound.Sound($"ringside/new/bigguy_var{currentQuestion}_3", beat + 1f, 1, 1, false, 0),
|
||||
new MultiSound.Sound($"ringside/new/bigguy_var{currentQuestion}_4", beat + 1.5f, 1, 1, false, 0.006),
|
||||
new MultiSound.Sound($"ringside/new/bigguy_var{currentQuestion}_5", beat + 2f, 1, 1, false, 0.009),
|
||||
new MultiSound.Sound($"ringside/new/mic_swoosh", beat + 2f, 1, 1, false, 0),
|
||||
new MultiSound.Sound($"ringside/en/bigguy_var{currentQuestion}_1", beat, 1, 1, false, youBeat),
|
||||
new MultiSound.Sound($"ringside/en/bigguy_var{currentQuestion}_2", beat + 0.75f, 1, 1, false, youBeat),
|
||||
new MultiSound.Sound($"ringside/en/bigguy_var{currentQuestion}_3", beat + 1f, 1, 1, false, 0),
|
||||
new MultiSound.Sound($"ringside/en/bigguy_var{currentQuestion}_4", beat + 1.5f, 1, 1, false, 0.006),
|
||||
new MultiSound.Sound($"ringside/en/bigguy_var{currentQuestion}_5", beat + 2f, 1, 1, false, 0.009),
|
||||
new MultiSound.Sound($"ringside/mic_swoosh", beat + 2f, 1, 1, false, 0),
|
||||
}, forcePlay: true);
|
||||
|
||||
ScheduleInput(beat, 2.5f, InputAction_BasicPress, JustBigGuyFirst, MissBigGuyOne, Nothing);
|
||||
@ -481,19 +481,19 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("ringside/new/pose_and", beat - 0.5f),
|
||||
new MultiSound.Sound("ringside/en/pose_and", beat - 0.5f),
|
||||
}, forcePlay: true);
|
||||
}
|
||||
int poseLine = variant;
|
||||
if (poseLine == 3) poseLine = UnityEngine.Random.Range(1, 3);
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound($"ringside/new/pose_var{poseLine}_1", beat, 1, 1, false, 0.02),
|
||||
new MultiSound.Sound($"ringside/new/pose_var{poseLine}_2", beat + 0.3333f, 1, 1, false, 0.00),
|
||||
new MultiSound.Sound($"ringside/new/pose_var{poseLine}_3", beat + 0.5f, 1, 1, false, 0.00),
|
||||
new MultiSound.Sound($"ringside/new/pose_var{poseLine}_4", beat + 0.75f, 1, 1, false, 0.022),
|
||||
new MultiSound.Sound($"ringside/new/pose_var{poseLine}_5", beat + 1f, 1, 1, false, 0.035),
|
||||
new MultiSound.Sound($"ringside/new/pose_var{poseLine}_6", beat + 1.8f, 1, 1, false, 0.00),
|
||||
new MultiSound.Sound($"ringside/en/pose_var{poseLine}_1", beat, 1, 1, false, 0.02),
|
||||
new MultiSound.Sound($"ringside/en/pose_var{poseLine}_2", beat + 0.3333f, 1, 1, false, 0.00),
|
||||
new MultiSound.Sound($"ringside/en/pose_var{poseLine}_3", beat + 0.5f, 1, 1, false, 0.00),
|
||||
new MultiSound.Sound($"ringside/en/pose_var{poseLine}_4", beat + 0.75f, 1, 1, false, 0.022),
|
||||
new MultiSound.Sound($"ringside/en/pose_var{poseLine}_5", beat + 1f, 1, 1, false, 0.035),
|
||||
new MultiSound.Sound($"ringside/en/pose_var{poseLine}_6", beat + 1.8f, 1, 1, false, 0.00),
|
||||
}, forcePlay: true);
|
||||
if (GameManager.instance.currentGame == "ringside")
|
||||
{
|
||||
@ -860,7 +860,7 @@ namespace HeavenStudio.Games
|
||||
wrestlerTransform.localScale = new Vector3(1.2f, 1.2f, 1f);
|
||||
int randomPose = UnityEngine.Random.Range(1, 7);
|
||||
wrestlerAnim.Play($"Pose{randomPose}", 0, 0);
|
||||
SoundByte.PlayOneShotGame($"ringside/new/badpose_{UnityEngine.Random.Range(1, 7)}");
|
||||
SoundByte.PlayOneShotGame($"ringside/badpose_{UnityEngine.Random.Range(1, 7)}");
|
||||
reporterHeadAnim.Play("Late", 0, 0);
|
||||
SoundByte.PlayOneShotGame($"ringside/huhaudience{UnityEngine.Random.Range(0, 2)}");
|
||||
BeatAction.New(instance, new List<BeatAction.Action>()
|
||||
|
@ -208,7 +208,7 @@ namespace HeavenStudio.Games.Loaders
|
||||
offSet = 0.034f;
|
||||
break;
|
||||
}
|
||||
SoundByte.PlayOneShot($"games/rockers/count/{e["count"]}", e.beat, 1, 1, false, null, offSet);
|
||||
SoundByte.PlayOneShot($"games/rockers/count/count{e["count"]}", e.beat, 1, 1, false, null, offSet);
|
||||
}
|
||||
},
|
||||
new GameAction("voiceLine", "Together Voice Line")
|
||||
|
@ -125,7 +125,7 @@ namespace HeavenStudio.Games.Scripts_Rockers
|
||||
if (pitches[i] == -1) continue;
|
||||
float pitch = SoundByte.GetPitchFromSemiTones(pitches[i], true);
|
||||
float volume = GetVolumeBasedOnAmountOfStrings(pitches.Length);
|
||||
string soundName = "rockers/strings/" + (gleeClub ? "gleeClub/" : "normal/" + (i + 1));
|
||||
string soundName = "rockers/strings/" + (gleeClub ? "gleeClub/gleeClub" : "normal/normal" + (i + 1));
|
||||
// Debug.Log("Pitch: " + pitch + " Volume: " + volume + " Name: " + soundName);
|
||||
stringSounds[i] = SoundByte.PlayOneShotGame(soundName, -1, pitch, volume, true);
|
||||
}
|
||||
@ -138,40 +138,40 @@ namespace HeavenStudio.Games.Scripts_Rockers
|
||||
Rockers.PremadeSamples.None => "",
|
||||
Rockers.PremadeSamples.BendG5 => "rockers/BendG5",
|
||||
Rockers.PremadeSamples.BendC6 => "rockers/BendC6",
|
||||
Rockers.PremadeSamples.ChordA => "rockers/rocker/ChordA",
|
||||
Rockers.PremadeSamples.ChordAsus4 => "rockers/rocker/ChordAsus4",
|
||||
Rockers.PremadeSamples.ChordBm => "rockers/rocker/ChordBm",
|
||||
Rockers.PremadeSamples.ChordCSharpm7 => "rockers/rocker/ChordC#m7",
|
||||
Rockers.PremadeSamples.ChordDmaj7 => "rockers/rocker/ChordDmaj7",
|
||||
Rockers.PremadeSamples.ChordDmaj9 => "rockers/rocker/ChordDmaj9",
|
||||
Rockers.PremadeSamples.ChordFSharp5 => "rockers/rocker/ChordF#5",
|
||||
Rockers.PremadeSamples.ChordG => "rockers/rocker/ChordG",
|
||||
Rockers.PremadeSamples.ChordG5 => "rockers/rocker/ChordG5",
|
||||
Rockers.PremadeSamples.ChordGdim7 => "rockers/rocker/ChordGdim7",
|
||||
Rockers.PremadeSamples.ChordGm => "rockers/rocker/ChordGm",
|
||||
Rockers.PremadeSamples.NoteASharp4 => "rockers/rocker/NoteA#4",
|
||||
Rockers.PremadeSamples.NoteA5 => "rockers/rocker/NoteA5",
|
||||
Rockers.PremadeSamples.PracticeChordD => "rockers/rocker/PracticeChordD",
|
||||
Rockers.PremadeSamples.Remix6ChordA => "rockers/rocker/Remix6ChordA",
|
||||
Rockers.PremadeSamples.Remix10ChordD => "rockers/rocker/Remix10ChordD",
|
||||
Rockers.PremadeSamples.Remix10ChordFSharpm => "rockers/rocker/Remix10ChordF#m",
|
||||
Rockers.PremadeSamples.DoremiChordA7 => "rockers/doremi/ChordA7",
|
||||
Rockers.PremadeSamples.DoremiChordAm7 => "rockers/doremi/ChordAm7",
|
||||
Rockers.PremadeSamples.DoremiChordC => "rockers/doremi/ChordC",
|
||||
Rockers.PremadeSamples.DoremiChordC7 => "rockers/doremi/ChordC7",
|
||||
Rockers.PremadeSamples.DoremiChordCadd9 => "rockers/doremi/ChordCadd9",
|
||||
Rockers.PremadeSamples.DoremiChordDm => "rockers/doremi/ChordDm",
|
||||
Rockers.PremadeSamples.DoremiChordDm7 => "rockers/doremi/ChordDm7",
|
||||
Rockers.PremadeSamples.DoremiChordEm => "rockers/doremi/ChordEm",
|
||||
Rockers.PremadeSamples.DoremiChordF => "rockers/doremi/ChordF",
|
||||
Rockers.PremadeSamples.DoremiChordFadd9 => "rockers/doremi/ChordFadd9",
|
||||
Rockers.PremadeSamples.DoremiChordFm => "rockers/doremi/ChordFm",
|
||||
Rockers.PremadeSamples.DoremiChordG => "rockers/doremi/ChordG",
|
||||
Rockers.PremadeSamples.DoremiChordG7 => "rockers/doremi/ChordG7",
|
||||
Rockers.PremadeSamples.DoremiChordGm => "rockers/doremi/ChordGm",
|
||||
Rockers.PremadeSamples.DoremiChordGsus4 => "rockers/doremi/ChordGsus4",
|
||||
Rockers.PremadeSamples.DoremiNoteA2 => "rockers/doremi/NoteA2",
|
||||
Rockers.PremadeSamples.DoremiNoteE2 => "rockers/doremi/NoteE2",
|
||||
Rockers.PremadeSamples.ChordA => "rockers/rocker/rockerChordA",
|
||||
Rockers.PremadeSamples.ChordAsus4 => "rockers/rocker/rockerChordAsus4",
|
||||
Rockers.PremadeSamples.ChordBm => "rockers/rocker/rockerChordBm",
|
||||
Rockers.PremadeSamples.ChordCSharpm7 => "rockers/rocker/rockerChordC#m7",
|
||||
Rockers.PremadeSamples.ChordDmaj7 => "rockers/rocker/rockerChordDmaj7",
|
||||
Rockers.PremadeSamples.ChordDmaj9 => "rockers/rocker/rockerChordDmaj9",
|
||||
Rockers.PremadeSamples.ChordFSharp5 => "rockers/rocker/rockerChordF#5",
|
||||
Rockers.PremadeSamples.ChordG => "rockers/rocker/rockerChordG",
|
||||
Rockers.PremadeSamples.ChordG5 => "rockers/rocker/rockerChordG5",
|
||||
Rockers.PremadeSamples.ChordGdim7 => "rockers/rocker/rockerChordGdim7",
|
||||
Rockers.PremadeSamples.ChordGm => "rockers/rocker/rockerChordGm",
|
||||
Rockers.PremadeSamples.NoteASharp4 => "rockers/rocker/rockerNoteA#4",
|
||||
Rockers.PremadeSamples.NoteA5 => "rockers/rocker/rockerNoteA5",
|
||||
Rockers.PremadeSamples.PracticeChordD => "rockers/rocker/rockerPracticeChordD",
|
||||
Rockers.PremadeSamples.Remix6ChordA => "rockers/rocker/rockerRemix6ChordA",
|
||||
Rockers.PremadeSamples.Remix10ChordD => "rockers/rocker/rockerRemix10ChordD",
|
||||
Rockers.PremadeSamples.Remix10ChordFSharpm => "rockers/rocker/rockerRemix10ChordF#m",
|
||||
Rockers.PremadeSamples.DoremiChordA7 => "rockers/doremi/doremiChordA7",
|
||||
Rockers.PremadeSamples.DoremiChordAm7 => "rockers/doremi/doremiChordAm7",
|
||||
Rockers.PremadeSamples.DoremiChordC => "rockers/doremi/doremiChordC",
|
||||
Rockers.PremadeSamples.DoremiChordC7 => "rockers/doremi/doremiChordC7",
|
||||
Rockers.PremadeSamples.DoremiChordCadd9 => "rockers/doremi/doremiChordCadd9",
|
||||
Rockers.PremadeSamples.DoremiChordDm => "rockers/doremi/doremiChordDm",
|
||||
Rockers.PremadeSamples.DoremiChordDm7 => "rockers/doremi/doremiChordDm7",
|
||||
Rockers.PremadeSamples.DoremiChordEm => "rockers/doremi/doremiChordEm",
|
||||
Rockers.PremadeSamples.DoremiChordF => "rockers/doremi/doremiChordF",
|
||||
Rockers.PremadeSamples.DoremiChordFadd9 => "rockers/doremi/doremiChordFadd9",
|
||||
Rockers.PremadeSamples.DoremiChordFm => "rockers/doremi/doremiChordFm",
|
||||
Rockers.PremadeSamples.DoremiChordG => "rockers/doremi/doremiChordG",
|
||||
Rockers.PremadeSamples.DoremiChordG7 => "rockers/doremi/doremiChordG7",
|
||||
Rockers.PremadeSamples.DoremiChordGm => "rockers/doremi/doremiChordGm",
|
||||
Rockers.PremadeSamples.DoremiChordGsus4 => "rockers/doremi/doremiChordGsus4",
|
||||
Rockers.PremadeSamples.DoremiNoteA2 => "rockers/doremi/doremiNoteA2",
|
||||
Rockers.PremadeSamples.DoremiNoteE2 => "rockers/doremi/doremiNoteE2",
|
||||
_ => throw new System.NotImplementedException(),
|
||||
};
|
||||
chordSound = SoundByte.PlayOneShotGame(soundName, -1, pitch, 1, true);
|
||||
|
@ -272,6 +272,7 @@ namespace HeavenStudio.Games
|
||||
var relevantInputs = GetAllInputsBetweenBeat(beat, beat + interval);
|
||||
relevantInputs.Sort((x, y) => x.beat.CompareTo(y.beat));
|
||||
|
||||
List<MultiSound.Sound> sounds = new();
|
||||
for (int i = 0; i < relevantInputs.Count; i++)
|
||||
{
|
||||
bool isHit = relevantInputs[i].datamodel == "tambourine/hit";
|
||||
@ -282,10 +283,12 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
MonkeyInput(inputBeat, isHit);
|
||||
}));
|
||||
sounds.Add(new MultiSound.Sound($"tambourine/monkey/{(isHit ? "hit" : "shake")}/m{(isHit ? "h" : "s")}{UnityEngine.Random.Range(1, 6)}", inputBeat));
|
||||
}
|
||||
}
|
||||
|
||||
BeatAction.New(this, actions);
|
||||
MultiSound.Play(sounds.ToArray(), true, true);
|
||||
|
||||
if (autoPassTurn)
|
||||
{
|
||||
@ -298,12 +301,10 @@ namespace HeavenStudio.Games
|
||||
if (hit)
|
||||
{
|
||||
monkeyAnimator.DoScaledAnimationAsync("MonkeySmack", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/monkey/hit/{UnityEngine.Random.Range(1, 6)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
monkeyAnimator.DoScaledAnimationAsync("MonkeyShake", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/monkey/shake/{UnityEngine.Random.Range(1, 6)}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,7 +336,7 @@ namespace HeavenStudio.Games
|
||||
|
||||
private void PassTurn(double beat, double intervalBeat, float intervalLength, float length)
|
||||
{
|
||||
SoundByte.PlayOneShotGame($"tambourine/monkey/turnPass/{UnityEngine.Random.Range(1, 6)}", beat);
|
||||
SoundByte.PlayOneShotGame($"tambourine/monkey/turnPass/tp{UnityEngine.Random.Range(1, 6)}", beat);
|
||||
List<BeatAction.Action> actions = new()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate
|
||||
@ -417,7 +418,7 @@ namespace HeavenStudio.Games
|
||||
if (state >= 1f || state <= -1f)
|
||||
{
|
||||
handsAnimator.DoScaledAnimationAsync("Smack", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/hit/{UnityEngine.Random.Range(1, 6)}");
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/hit/ph{UnityEngine.Random.Range(1, 6)}");
|
||||
SoundByte.PlayOneShotGame("tambourine/miss");
|
||||
sweatAnimator.DoScaledAnimationAsync("Sweating", 0.5f);
|
||||
misses++;
|
||||
@ -435,7 +436,7 @@ namespace HeavenStudio.Games
|
||||
if (state >= 1f || state <= -1f)
|
||||
{
|
||||
handsAnimator.DoScaledAnimationAsync("Shake", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/shake/{UnityEngine.Random.Range(1, 6)}");
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/shake/ps{UnityEngine.Random.Range(1, 6)}");
|
||||
SoundByte.PlayOneShotGame("tambourine/miss");
|
||||
sweatAnimator.DoScaledAnimationAsync("Sweating", 0.5f);
|
||||
misses++;
|
||||
@ -454,12 +455,12 @@ namespace HeavenStudio.Games
|
||||
if (hit)
|
||||
{
|
||||
handsAnimator.DoScaledAnimationAsync("Smack", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/hit/{UnityEngine.Random.Range(1, 6)}");
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/hit/ph{UnityEngine.Random.Range(1, 6)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
handsAnimator.DoScaledAnimationAsync("Shake", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/shake/{UnityEngine.Random.Range(1, 6)}");
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/shake/ps{UnityEngine.Random.Range(1, 6)}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,6 @@ namespace HeavenStudio.Games.Scripts_WorkingDough
|
||||
Update();
|
||||
return;
|
||||
}
|
||||
Debug.Log($"hit at {beat}");
|
||||
currentState = State.Hit;
|
||||
if (big)
|
||||
{
|
||||
|
@ -419,7 +419,6 @@ namespace HeavenStudio.Games
|
||||
|
||||
public void SpawnPlayerBall(double beat, bool isBig, bool hasGandw)
|
||||
{
|
||||
Debug.Log($"Spawned player ball for beat {beat} (big: {isBig})");
|
||||
var objectToSpawn = isBig ? playerEnterBigBall : playerEnterSmallBall;
|
||||
var spawnedBall = GameObject.Instantiate(objectToSpawn, ballHolder);
|
||||
|
||||
|
@ -363,13 +363,14 @@ namespace HeavenStudio
|
||||
|
||||
public List<string> tags;
|
||||
public string defaultLocale = "en";
|
||||
public string wantAssetBundle = "";
|
||||
public string wantAssetBundle = null;
|
||||
public List<string> supportedLocales;
|
||||
public bool inferred;
|
||||
|
||||
public bool usesAssetBundle => wantAssetBundle != "";
|
||||
public bool usesAssetBundle => wantAssetBundle is not null or "";
|
||||
public bool hasLocales => supportedLocales.Count > 0;
|
||||
public bool AssetsLoaded => ((hasLocales && localeLoaded && currentLoadedLocale == defaultLocale) || (!hasLocales)) && commonLoaded;
|
||||
public bool AssetsLoaded => ((hasLocales && localeLoaded && currentLoadedLocale == defaultLocale) || (!hasLocales)) && commonLoaded && loadComplete;
|
||||
public bool AlreadyLoading => alreadyLoading;
|
||||
public bool SequencesPreloaded => soundSequences != null;
|
||||
public string LoadableName => inferred ? "noGame" : name;
|
||||
public GameObject LoadedPrefab => loadedPrefab;
|
||||
@ -382,8 +383,8 @@ namespace HeavenStudio
|
||||
private bool localeLoaded = false;
|
||||
private bool localePreloaded = false;
|
||||
private GameObject loadedPrefab = null;
|
||||
private Dictionary<string, AudioClip> commonAudioClips;
|
||||
private Dictionary<string, AudioClip> localeAudioClips;
|
||||
|
||||
bool loadComplete = false;
|
||||
|
||||
private SoundSequence.SequenceKeyValue[] soundSequences = null;
|
||||
|
||||
@ -392,10 +393,8 @@ namespace HeavenStudio
|
||||
get => soundSequences;
|
||||
set => soundSequences = value;
|
||||
}
|
||||
public Dictionary<string, AudioClip> CommonAudioClips => commonAudioClips;
|
||||
public Dictionary<string, AudioClip> LocaleAudioClips => localeAudioClips;
|
||||
|
||||
public Minigame(string name, string displayName, string color, bool hidden, bool fxOnly, List<GameAction> actions, List<string> tags = null, string assetBundle = "", string defaultLocale = "en", List<string> supportedLocales = null, bool inferred = false)
|
||||
public Minigame(string name, string displayName, string color, bool hidden, bool fxOnly, List<GameAction> actions, List<string> tags = null, string wantAssetBundle = null, string defaultLocale = "en", List<string> supportedLocales = null, bool inferred = false)
|
||||
{
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
@ -405,7 +404,7 @@ namespace HeavenStudio
|
||||
this.fxOnly = fxOnly;
|
||||
|
||||
this.tags = tags ?? new List<string>();
|
||||
this.wantAssetBundle = assetBundle;
|
||||
this.wantAssetBundle = wantAssetBundle;
|
||||
this.defaultLocale = defaultLocale;
|
||||
this.supportedLocales = supportedLocales ?? new List<string>();
|
||||
this.inferred = inferred;
|
||||
@ -414,7 +413,7 @@ namespace HeavenStudio
|
||||
this.splitColorR = null;
|
||||
}
|
||||
|
||||
public Minigame(string name, string displayName, string color, string splitColorL, string splitColorR, bool hidden, bool fxOnly, List<GameAction> actions, List<string> tags = null, string assetBundle = "", string defaultLocale = "en", List<string> supportedLocales = null, bool inferred = false)
|
||||
public Minigame(string name, string displayName, string color, string splitColorL, string splitColorR, bool hidden, bool fxOnly, List<GameAction> actions, List<string> tags = null, string wantAssetBundle = null, string defaultLocale = "en", List<string> supportedLocales = null, bool inferred = false)
|
||||
{
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
@ -424,7 +423,7 @@ namespace HeavenStudio
|
||||
this.fxOnly = fxOnly;
|
||||
|
||||
this.tags = tags ?? new List<string>();
|
||||
this.wantAssetBundle = assetBundle;
|
||||
this.wantAssetBundle = wantAssetBundle;
|
||||
this.defaultLocale = defaultLocale;
|
||||
this.supportedLocales = supportedLocales ?? new List<string>();
|
||||
this.inferred = inferred;
|
||||
@ -475,11 +474,17 @@ namespace HeavenStudio
|
||||
return bundleCommon;
|
||||
}
|
||||
|
||||
public async UniTask LoadAssetsAsync()
|
||||
bool alreadyLoading = false;
|
||||
public async UniTaskVoid LoadAssetsAsync()
|
||||
{
|
||||
if (AssetsLoaded || !usesAssetBundle) return;
|
||||
if (alreadyLoading || AssetsLoaded || !usesAssetBundle) return;
|
||||
loadComplete = false;
|
||||
alreadyLoading = true;
|
||||
await UniTask.WhenAll(LoadCommonAssetBundleAsync(), LoadLocalizedAssetBundleAsync());
|
||||
await UniTask.WhenAll(LoadGamePrefabAsync(), LoadCommonAudioClips(), LoadLocalizedAudioClips());
|
||||
SoundByte.PreloadGameAudioClips(this);
|
||||
alreadyLoading = false;
|
||||
loadComplete = true;
|
||||
}
|
||||
|
||||
public async UniTask LoadCommonAssetBundleAsync()
|
||||
@ -533,16 +538,23 @@ namespace HeavenStudio
|
||||
if (!commonLoaded) return;
|
||||
if (bundleCommon == null) return;
|
||||
|
||||
UnityEngine.Object asset = await bundleCommon.LoadAssetAsync<GameObject>(name).ToUniTask(timing: PlayerLoopTiming.PreLateUpdate);
|
||||
loadedPrefab = asset as GameObject;
|
||||
AssetBundleRequest request = bundleCommon.LoadAssetAsync<GameObject>(name);
|
||||
request.completed += (op) => OnPrefabLoaded(op as AssetBundleRequest);
|
||||
await request;
|
||||
loadedPrefab = request.asset as GameObject;
|
||||
}
|
||||
|
||||
// load sound sequences here for now
|
||||
// this is taxing and is still done synchronously
|
||||
// move sequences to their own assets so that we don't have to look up a component
|
||||
if (loadedPrefab.TryGetComponent<Games.Minigame>(out Games.Minigame minigame))
|
||||
void OnPrefabLoaded(AssetBundleRequest request)
|
||||
{
|
||||
GameObject prefab = request.asset as GameObject;
|
||||
// // load sound sequences here for now
|
||||
// // this is taxing and is still done synchronously
|
||||
// // move sequences to their own assets so that we don't have to look up a component
|
||||
if (prefab.TryGetComponent<Games.Minigame>(out Games.Minigame minigame))
|
||||
{
|
||||
soundSequences = minigame.SoundSequences;
|
||||
}
|
||||
loadedPrefab = prefab;
|
||||
}
|
||||
|
||||
public GameObject LoadGamePrefab()
|
||||
@ -558,8 +570,6 @@ namespace HeavenStudio
|
||||
if (!commonLoaded) return;
|
||||
if (bundleCommon == null) return;
|
||||
|
||||
commonAudioClips = new();
|
||||
|
||||
var assets = bundleCommon.LoadAllAssetsAsync();
|
||||
await assets;
|
||||
}
|
||||
@ -569,8 +579,6 @@ namespace HeavenStudio
|
||||
if (!localeLoaded) return;
|
||||
if (bundleLocalized == null) return;
|
||||
|
||||
localeAudioClips = new();
|
||||
|
||||
var assets = bundleLocalized.LoadAllAssetsAsync();
|
||||
await assets;
|
||||
}
|
||||
@ -578,8 +586,6 @@ namespace HeavenStudio
|
||||
public async UniTask UnloadAllAssets()
|
||||
{
|
||||
if (!usesAssetBundle) return;
|
||||
commonAudioClips.Clear();
|
||||
localeAudioClips.Clear();
|
||||
if (loadedPrefab != null)
|
||||
{
|
||||
loadedPrefab = null;
|
||||
@ -598,6 +604,8 @@ namespace HeavenStudio
|
||||
localeLoaded = false;
|
||||
localePreloaded = false;
|
||||
}
|
||||
SoundByte.UnloadAudioClips(name);
|
||||
loadComplete = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -746,35 +754,6 @@ namespace HeavenStudio
|
||||
GameManager.instance.ToggleInputs(eventCaller.currentEntity["toggle"]);
|
||||
}
|
||||
),
|
||||
|
||||
// These are still here for backwards-compatibility but are hidden in the editor
|
||||
new GameAction("flash", "", 1f, true,
|
||||
new List<Param>()
|
||||
{
|
||||
new Param("colorA", Color.white, "Start Color"),
|
||||
new Param("colorB", Color.white, "End Color"),
|
||||
new Param("valA", new EntityTypes.Float(0, 1, 1), "Start Opacity"),
|
||||
new Param("valB", new EntityTypes.Float(0, 1, 0), "End Opacity"),
|
||||
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
|
||||
},
|
||||
hidden: true
|
||||
),
|
||||
new GameAction("move camera", "", 1f, true, new List<Param>()
|
||||
{
|
||||
new Param("valA", new EntityTypes.Float(-50, 50, 0), "Right / Left"),
|
||||
new Param("valB", new EntityTypes.Float(-50, 50, 0), "Up / Down"),
|
||||
new Param("valC", new EntityTypes.Float(-0, 250, 10), "In / Out"),
|
||||
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease Type")
|
||||
},
|
||||
hidden: true ),
|
||||
new GameAction("rotate camera", "", 1f, true, new List<Param>()
|
||||
{
|
||||
new Param("valA", new EntityTypes.Integer(-360, 360, 0), "Pitch"),
|
||||
new Param("valB", new EntityTypes.Integer(-360, 360, 0), "Yaw"),
|
||||
new Param("valC", new EntityTypes.Integer(-360, 360, 0), "Roll"),
|
||||
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease Type")
|
||||
},
|
||||
hidden: true ),
|
||||
}),
|
||||
|
||||
new Minigame("countIn", "Count-Ins", "", false, true, new List<GameAction>()
|
||||
|
@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Util
|
||||
@ -11,6 +14,8 @@ namespace HeavenStudio.Util
|
||||
static AudioSource oneShotAudioSource;
|
||||
static int soundIdx = 0;
|
||||
|
||||
static Dictionary<string, AudioClip> audioClips = new Dictionary<string, AudioClip>();
|
||||
|
||||
public enum AudioType
|
||||
{
|
||||
OGG,
|
||||
@ -32,12 +37,6 @@ namespace HeavenStudio.Util
|
||||
/// </summary>
|
||||
public static void BasicCheck()
|
||||
{
|
||||
if (FindJukebox() == null)
|
||||
{
|
||||
GameObject Jukebox = new GameObject("Jukebox");
|
||||
Jukebox.AddComponent<AudioSource>();
|
||||
Jukebox.tag = "Jukebox";
|
||||
}
|
||||
if (oneShotAudioSourceObject == null)
|
||||
{
|
||||
oneShotAudioSourceObject = new GameObject("OneShot Audio Source");
|
||||
@ -46,14 +45,6 @@ namespace HeavenStudio.Util
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject FindJukebox()
|
||||
{
|
||||
if (GameObject.FindGameObjectWithTag("Jukebox") != null)
|
||||
return GameObject.FindGameObjectWithTag("Jukebox");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops all currently playing sounds.
|
||||
/// </summary>
|
||||
@ -87,32 +78,181 @@ namespace HeavenStudio.Util
|
||||
}
|
||||
}
|
||||
|
||||
public static void PreloadGameAudioClips(Minigames.Minigame inf)
|
||||
{
|
||||
if (inf.usesAssetBundle)
|
||||
{
|
||||
var cmnAb = inf.GetCommonAssetBundle();
|
||||
if (cmnAb != null)
|
||||
{
|
||||
cmnAb.LoadAllAssetsAsync<AudioClip>().completed += (op) =>
|
||||
{
|
||||
foreach (var clip in (op as AssetBundleRequest).allAssets.Cast<AudioClip>())
|
||||
{
|
||||
OnResourceLoaded(clip, $"games/{inf.name}/{clip.name}");
|
||||
}
|
||||
};
|
||||
}
|
||||
var locAb = inf.GetLocalizedAssetBundle();
|
||||
if (locAb != null)
|
||||
{
|
||||
locAb.LoadAllAssetsAsync<AudioClip>().completed += (op) =>
|
||||
{
|
||||
foreach (var clip in (op as AssetBundleRequest).allAssets.Cast<AudioClip>())
|
||||
{
|
||||
OnResourceLoaded(clip, $"games/{inf.name}/{clip.name}");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string path = $"Sfx/games/{inf.name}";
|
||||
var clips = Resources.LoadAll<AudioClip>(path);
|
||||
foreach (var clip in clips)
|
||||
{
|
||||
OnResourceLoaded(clip, $"games/{inf.name}/{clip.name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void PreloadGameAudioClips(string game)
|
||||
{
|
||||
var inf = GameManager.instance.GetGameInfo(game);
|
||||
PreloadGameAudioClips(inf);
|
||||
}
|
||||
|
||||
public static void PreloadAudioClipAsync(string name, string game)
|
||||
{
|
||||
var inf = GameManager.instance.GetGameInfo(game);
|
||||
if (inf != null)
|
||||
{
|
||||
name = $"games/{name}";
|
||||
}
|
||||
if (audioClips.ContainsKey(name)) return;
|
||||
if (inf.usesAssetBundle)
|
||||
{
|
||||
var cmnAb = inf.GetCommonAssetBundle();
|
||||
if (cmnAb != null && cmnAb.Contains(name))
|
||||
{
|
||||
var request = cmnAb.LoadAssetAsync<AudioClip>(name);
|
||||
request.completed += (op) =>
|
||||
{
|
||||
OnResourceLoaded((op as ResourceRequest).asset as AudioClip, $"{game}/{name}");
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var locAb = inf.GetLocalizedAssetBundle();
|
||||
if (locAb != null && locAb.Contains(name))
|
||||
{
|
||||
var request = locAb.LoadAssetAsync<AudioClip>(name);
|
||||
request.completed += (op) =>
|
||||
{
|
||||
OnResourceLoaded((op as ResourceRequest).asset as AudioClip, $"{game}/{name}");
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PreloadAudioClipAsync($"{game}/{name}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void PreloadAudioClipAsync(string name)
|
||||
{
|
||||
if (audioClips.ContainsKey(name)) return;
|
||||
string path = $"Sfx/{name}";
|
||||
ResourceRequest request = Resources.LoadAsync<AudioClip>(path);
|
||||
request.completed += (op) =>
|
||||
{
|
||||
OnResourceLoaded((op as ResourceRequest).asset as AudioClip, name);
|
||||
};
|
||||
}
|
||||
|
||||
static void OnResourceLoaded(AudioClip clip, string name)
|
||||
{
|
||||
if (audioClips.ContainsKey(name))
|
||||
{
|
||||
audioClips[name] = clip;
|
||||
}
|
||||
else
|
||||
{
|
||||
audioClips.Add(name, clip);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnloadAudioClips(params string[] names)
|
||||
{
|
||||
foreach (string s in names)
|
||||
{
|
||||
if (audioClips.ContainsKey(s)) audioClips.Remove(s);
|
||||
}
|
||||
Resources.UnloadUnusedAssets();
|
||||
}
|
||||
|
||||
public static void UnloadAudioClips()
|
||||
{
|
||||
audioClips.Clear();
|
||||
Resources.UnloadUnusedAssets();
|
||||
}
|
||||
|
||||
public static void UnloadAudioClips(string game)
|
||||
{
|
||||
string[] split;
|
||||
foreach (string s in audioClips.Where(x =>
|
||||
{
|
||||
split = x.Key.Split('/');
|
||||
return split.Length > 2 && split[0] == "games" && split[1] == game;
|
||||
}).Select(x => x.Key).ToList())
|
||||
{
|
||||
audioClips.Remove(s);
|
||||
}
|
||||
Resources.UnloadUnusedAssets();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the length of an audio clip
|
||||
/// </summary>
|
||||
public static double GetClipLength(string name, float pitch = 1f, string game = null)
|
||||
{
|
||||
AudioClip clip = null;
|
||||
string soundName = name.Split('/')[^1];
|
||||
if (game != null)
|
||||
{
|
||||
string soundName = name.Split('/')[2];
|
||||
var inf = GameManager.instance.GetGameInfo(game);
|
||||
//first try the game's common assetbundle
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from common");
|
||||
clip = inf.GetCommonAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
//then the localized one
|
||||
if (clip == null)
|
||||
string cachedName = $"games/{game}/{soundName}";
|
||||
if (audioClips.ContainsKey(cachedName))
|
||||
{
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from locale");
|
||||
clip = inf.GetLocalizedAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
clip = audioClips[cachedName];
|
||||
}
|
||||
else
|
||||
{
|
||||
var inf = GameManager.instance.GetGameInfo(game);
|
||||
//first try the game's common assetbundle
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from common");
|
||||
clip = inf.GetCommonAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
//then the localized one
|
||||
if (clip == null)
|
||||
{
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from locale");
|
||||
clip = inf.GetLocalizedAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//can't load from assetbundle, load from resources
|
||||
if (clip == null)
|
||||
{
|
||||
// Debug.Log("Jukebox loading sound " + name + " from resources");
|
||||
clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
if (audioClips.ContainsKey(name))
|
||||
{
|
||||
clip = audioClips[name];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Debug.Log("Jukebox loading sound " + name + " from resources");
|
||||
clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
}
|
||||
}
|
||||
|
||||
if (clip == null)
|
||||
@ -147,26 +287,41 @@ namespace HeavenStudio.Util
|
||||
public static Sound PlayOneShot(string name, double beat = -1, float pitch = 1f, float volume = 1f, bool looping = false, string game = null, double offset = 0f)
|
||||
{
|
||||
AudioClip clip = null;
|
||||
string soundName = name.Split('/')[^1];
|
||||
if (game != null)
|
||||
{
|
||||
string soundName = name.Split('/')[2];
|
||||
var inf = GameManager.instance.GetGameInfo(game);
|
||||
//first try the game's common assetbundle
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from common");
|
||||
clip = inf.GetCommonAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
//then the localized one
|
||||
if (clip == null)
|
||||
string cachedName = $"games/{game}/{soundName}";
|
||||
if (audioClips.ContainsKey(cachedName))
|
||||
{
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from locale");
|
||||
clip = inf.GetLocalizedAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
clip = audioClips[cachedName];
|
||||
}
|
||||
else
|
||||
{
|
||||
var inf = GameManager.instance.GetGameInfo(game);
|
||||
//first try the game's common assetbundle
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from common");
|
||||
clip = inf.GetCommonAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
//then the localized one
|
||||
if (clip == null)
|
||||
{
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from locale");
|
||||
clip = inf.GetLocalizedAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//can't load from assetbundle, load from resources
|
||||
if (clip == null)
|
||||
{
|
||||
// Debug.Log("Jukebox loading sound " + name + " from resources");
|
||||
clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
if (audioClips.ContainsKey(name))
|
||||
{
|
||||
clip = audioClips[name];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Debug.Log("Jukebox loading sound " + name + " from resources");
|
||||
clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
}
|
||||
}
|
||||
|
||||
if (looping || beat != -1 || pitch != 1f)
|
||||
@ -203,26 +358,43 @@ namespace HeavenStudio.Util
|
||||
public static Sound PlayOneShotScheduled(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false, string game = null)
|
||||
{
|
||||
Sound snd = GetAvailableScheduledSound();
|
||||
|
||||
AudioClip clip = null;
|
||||
string soundName = name.Split('/')[^1];
|
||||
if (game != null)
|
||||
{
|
||||
string soundName = name.Split('/')[2];
|
||||
var inf = GameManager.instance.GetGameInfo(game);
|
||||
//first try the game's common assetbundle
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from common");
|
||||
clip = inf.GetCommonAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
//then the localized one
|
||||
if (clip == null)
|
||||
string cachedName = $"games/{game}/{soundName}";
|
||||
if (audioClips.ContainsKey(cachedName))
|
||||
{
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from locale");
|
||||
clip = inf.GetLocalizedAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
clip = audioClips[cachedName];
|
||||
}
|
||||
else
|
||||
{
|
||||
var inf = GameManager.instance.GetGameInfo(game);
|
||||
//first try the game's common assetbundle
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from common");
|
||||
clip = inf.GetCommonAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
//then the localized one
|
||||
if (clip == null)
|
||||
{
|
||||
// Debug.Log("Jukebox loading sound " + soundName + " from locale");
|
||||
clip = inf.GetLocalizedAssetBundle()?.LoadAsset<AudioClip>(soundName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//can't load from assetbundle, load from resources
|
||||
if (clip == null)
|
||||
clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
{
|
||||
if (audioClips.ContainsKey(name))
|
||||
{
|
||||
clip = audioClips[name];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Debug.Log("Jukebox loading sound " + name + " from resources");
|
||||
clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
}
|
||||
}
|
||||
|
||||
// abort if no clip found
|
||||
|
||||
|
Reference in New Issue
Block a user