Nail Carpenter(WIP) #Fixed audio bugs in an unbeautiful implementation.

This commit is contained in:
fu-majime 2024-03-04 12:34:47 +09:00
parent c1c2c85258
commit 33b1e5383a
2 changed files with 17 additions and 6 deletions

View file

@ -16,21 +16,25 @@ namespace HeavenStudio.Games.Loaders
{
new GameAction("puddingNail", "Pudding Nail")
{
function = delegate {NailCarpenter.instance.PlaySound();},
defaultLength = 4f,
resizable = true
},
new GameAction("cherryNail", "Cherry Nail")
{
function = delegate {NailCarpenter.instance.PlaySound();},
defaultLength = 2f,
resizable = true
},
new GameAction("cakeNail", "Cake Nail")
{
function = delegate {NailCarpenter.instance.PlaySound();},
defaultLength = 2f,
resizable = true
},
new GameAction("cakeLongNail", "Cake Long Nail")
{
function = delegate {NailCarpenter.instance.PlaySound();},
defaultLength = 2f,
resizable = true
},
@ -187,7 +191,6 @@ namespace HeavenStudio.Games
List<RiqEntity> cakeNailEvents = entities.FindAll(v => v.datamodel == "nailCarpenter/cakeNail");
List<RiqEntity> cklNailEvents = entities.FindAll(v => v.datamodel == "nailCarpenter/cakeLongNail");
var sounds = new List<MultiSound.Sound>(){};
var cherryTargetBeats = new List<double>(){};
// Spawn cake and nail.
@ -307,10 +310,6 @@ namespace HeavenStudio.Games
}
}
}
if (sounds.Count > 0) {
MultiSound.Play(sounds.ToArray(), forcePlay: true);
}
}
public override void OnPlay(double beat)
@ -388,5 +387,18 @@ namespace HeavenStudio.Games
return false;
}
// MultiSound.Play may not work in OnPlay (OnGameSwitch?), so I play the audio using an alternative method.
List<MultiSound.Sound> sounds = new List<MultiSound.Sound>(){};
bool isPlayed = false;
public void PlaySound()
{
if (isPlayed) return;
if (sounds.Count > 0) {
MultiSound.Play(sounds.ToArray());
isPlayed = true;
sounds = null;
}
}
}
}

View file

@ -36,7 +36,6 @@ namespace HeavenStudio.Games.Scripts_NailCarpenter
}
private void AwakeAnim()
{
Debug.Log(sweetType);
switch(sweetType)
{
case sweetsType.Pudding: