Better Sound Sequences (#190)

* add way of creating sound sequences in inspector

- actually implement GameAction preFunction
- implement sound scheduling for Jukebox and MultiSound

* Dj School: fix turntable effect being parented to root

* Pajama Party: fix sleep action type not carrying over between transitions
This commit is contained in:
minenice55
2023-01-04 23:04:31 -05:00
committed by GitHub
parent 22133a5c54
commit 87d20b8c8f
28 changed files with 392 additions and 108 deletions

View File

@ -160,7 +160,7 @@ namespace HeavenStudio.Games.Scripts_DJSchool
tableAnim.speed = 1;
tableAnim.Play("Student_Turntable_Swipe", 0, 0);
Instantiate(slamFX).SetActive(true);
Instantiate(slamFX, this.transform.parent).SetActive(true);
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
}
else
@ -177,7 +177,7 @@ namespace HeavenStudio.Games.Scripts_DJSchool
tableAnim.speed = 1;
tableAnim.Play("Student_Turntable_Swipe", 0, 0);
Instantiate(slamFX).SetActive(true);
Instantiate(slamFX, this.transform.parent).SetActive(true);
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
}

View File

@ -182,7 +182,6 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
Spectators = new List<GameObject>();
idolAnimator = Arisa.GetComponent<Animator>();
@ -528,12 +527,7 @@ namespace HeavenStudio.Games
public void CallHai(float beat, bool noSound = false, int type = 0)
{
if (!noSound)
MultiSound.Play(new MultiSound.Sound[] {
new MultiSound.Sound("fanClub/arisa_hai_1_jp", beat),
new MultiSound.Sound("fanClub/arisa_hai_2_jp", beat + 1f),
new MultiSound.Sound("fanClub/arisa_hai_3_jp", beat + 2f),
});
PlaySoundSequence("arisa_hai", beat);
responseToggle = false;
DisableBop(beat, 8f);
@ -556,12 +550,7 @@ namespace HeavenStudio.Games
new BeatAction.Action(beat + 7f, delegate { PlayOneClap(beat + 7f); DoIdolClaps();}),
});
MultiSound.Play(new MultiSound.Sound[] {
new MultiSound.Sound("fanClub/crowd_hai_jp", beat + 4f),
new MultiSound.Sound("fanClub/crowd_hai_jp", beat + 5f),
new MultiSound.Sound("fanClub/crowd_hai_jp", beat + 6f),
new MultiSound.Sound("fanClub/crowd_hai_jp", beat + 7f),
});
PlaySoundSequence("crowd_hai", beat + 4f);
}
public static void WarnHai(float beat, bool noSound = false, int type = 0)
@ -586,27 +575,12 @@ namespace HeavenStudio.Games
bool doJump = (responseType == (int) KamoneResponseType.Jump || responseType == (int) KamoneResponseType.JumpFast);
bool isBig = (responseType == (int) KamoneResponseType.ThroughFast || responseType == (int) KamoneResponseType.JumpFast);
DisableResponse(beat, 2f);
if (isBig)
if (!noSound)
{
if (!noSound)
{
MultiSound.Play(new MultiSound.Sound[] {
new MultiSound.Sound("fanClub/arisa_ka_fast_jp", beat),
new MultiSound.Sound("fanClub/arisa_mo_fast_jp", beat + 0.25f),
new MultiSound.Sound("fanClub/arisa_ne_fast_jp", beat + 0.5f),
});
}
}
else
{
if (!noSound)
{
MultiSound.Play(new MultiSound.Sound[] {
new MultiSound.Sound("fanClub/arisa_ka_jp", beat),
new MultiSound.Sound("fanClub/arisa_mo_jp", beat + 0.5f, offset: 0.07407407f),
new MultiSound.Sound("fanClub/arisa_ne_jp", beat + 1f, offset: 0.07407407f),
});
}
if (isBig)
PlaySoundSequence("arisa_kamone_fast", beat);
else
PlaySoundSequence("arisa_kamone", beat);
}
responseToggle = true;
@ -640,12 +614,7 @@ namespace HeavenStudio.Games
}),
});
MultiSound.Play(new MultiSound.Sound[] {
new MultiSound.Sound("fanClub/crowd_ka_jp", beat + 2f),
new MultiSound.Sound("fanClub/crowd_mo_jp", beat + 3.5f),
new MultiSound.Sound("fanClub/crowd_ne_jp", beat + 4f),
new MultiSound.Sound("fanClub/crowd_hey_jp", beat + 5f),
});
PlaySoundSequence("crowd_kamone", beat + 2f);
}
public static void WarnKamone(float beat, bool noSound = false, int type = 0, int responseType = (int) KamoneResponseType.Through)
@ -679,11 +648,11 @@ namespace HeavenStudio.Games
const float BIGCALL_LENGTH = 2.75f;
public void CallBigReady(float beat, bool noSound = false)
{
if (!noSound)
PlaySoundSequence("crowd_big_ready", beat);
Prepare(beat + 1.5f);
Prepare(beat + 2f);
if (!noSound)
Jukebox.PlayOneShotGame("fanClub/crowd_big_ready");
DisableSpecBop(beat, 3.75f);
@ -701,7 +670,7 @@ namespace HeavenStudio.Games
{
wantBigReady = beat;
if (noSound) return;
Jukebox.PlayOneShotGame("fanClub/crowd_big_ready");
Jukebox.PlayOneShotGame("fanClub/crowd_big_ready", beat);
}
public void ContinueBigReady(float beat)

View File

@ -2,11 +2,15 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
namespace HeavenStudio.Games
{
public class Minigame : MonoBehaviour
{
public static float earlyTime = 0.1f, perfectTime = 0.08f, aceEarlyTime = 0.025f, aceLateTime = 0.025f, lateTime = 0.08f, endTime = 0.1f;
[SerializeField] public SoundSequence.SequenceKeyValue[] SoundSequences;
public List<Minigame.Eligible> EligibleHits = new List<Minigame.Eligible>();
[System.Serializable]
@ -211,5 +215,18 @@ namespace HeavenStudio.Games
return sameTime;
}
public MultiSound PlaySoundSequence(string name, float startBeat)
{
foreach (SoundSequence.SequenceKeyValue pair in SoundSequences)
{
if (pair.name == name)
{
return pair.sequence.Play(startBeat);
}
}
Debug.LogWarning($"Sound sequence {name} not found in game {this.name} (did you build AssetBundles?)");
return null;
}
}
}

View File

@ -37,7 +37,7 @@ namespace HeavenStudio.Games.Loaders
new Param("type", PajamaParty.SleepType.Normal, "Sleep Type", "Type of sleep action to use"),
new Param("toggle", false, "Alt. Animation", "Use an alternate animation for Mako")
},
inactiveFunction = delegate {var e = eventCaller.currentEntity; PajamaParty.WarnSleepSequence(e.beat, e["toggle"]);}
inactiveFunction = delegate {var e = eventCaller.currentEntity; PajamaParty.WarnSleepSequence(e.beat, e["toggle"], e["type"]);}
},
new GameAction("throw", "Throw Pillows")
{
@ -280,7 +280,7 @@ namespace HeavenStudio.Games
});
}
public static void WarnSleepSequence(float beat, bool alt = false)
public static void WarnSleepSequence(float beat, bool alt = false, int action = (int) PajamaParty.SleepType.Normal)
{
MultiSound.Play(new MultiSound.Sound[] {
new MultiSound.Sound("pajamaParty/siesta1", beat),
@ -291,6 +291,7 @@ namespace HeavenStudio.Games
}, forcePlay: true);
WantSleepSequence = beat;
WantSleepType = alt;
WantSleepAction = action;
}
public void DoBedImpact()