Merge pull request #38 from jakobwcrowe/master

Space Soccer and Karate Man tweaks
This commit is contained in:
Jenny Crowe 2022-02-14 06:49:19 -07:00 committed by GitHub
commit 07b15ddf31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View file

@ -8,6 +8,8 @@ namespace RhythmHeavenMania.Games.KarateMan
{ {
public class KarateMan : Minigame public class KarateMan : Minigame
{ {
const float hitVoiceOffset = 0.042f;
public GameObject Pot, Bomb; public GameObject Pot, Bomb;
public KarateJoe KarateJoe; public KarateJoe KarateJoe;
@ -153,6 +155,7 @@ namespace RhythmHeavenMania.Games.KarateMan
} }
} }
List<Beatmap.Entity> cuedVoices = new List<Beatmap.Entity>(); // "Hit" voices cued in advance are stored here so they aren't called multiple times in Update().
private void Update() private void Update()
{ {
if (Conductor.instance.ReportBeat(ref newBeat)) if (Conductor.instance.ReportBeat(ref newBeat))
@ -193,6 +196,19 @@ namespace RhythmHeavenMania.Games.KarateMan
prepare.length = 0; prepare.length = 0;
} }
} }
// Call "hit" voice slightly early to account for sound offset.
var hitVoiceEvents = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "karateman/hit3" || c.datamodel == "karateman/hit4");
for (int i = 0; i < hitVoiceEvents.Count; i++)
{
var hitEvent = hitVoiceEvents[i];
var timeToEvent = hitEvent.beat - Conductor.instance.songPositionInBeats;
if (timeToEvent <= 1f && timeToEvent > 0f && !cuedVoices.Contains(hitEvent))
{
cuedVoices.Add(hitEvent);
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("karateman/hit", hitEvent.beat - hitVoiceOffset * Conductor.instance.songBpm / 60f) });
}
}
} }
public void BGFXOn() public void BGFXOn()
@ -214,7 +230,7 @@ namespace RhythmHeavenMania.Games.KarateMan
public void Hit3(float beat) public void Hit3(float beat)
{ {
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("karateman/hit", beat), new MultiSound.Sound("karateman/three", beat + 0.5f) }); MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("karateman/three", beat + 0.5f) });
GameObject hit3 = Instantiate(HIT3Ref, this.transform); GameObject hit3 = Instantiate(HIT3Ref, this.transform);
hit3.transform.GetChild(0).GetChild(1).GetComponent<SpriteRenderer>().sprite = Numbers[2]; hit3.transform.GetChild(0).GetChild(1).GetComponent<SpriteRenderer>().sprite = Numbers[2];
BeatAction.New(hit3, new List<BeatAction.Action>() BeatAction.New(hit3, new List<BeatAction.Action>()
@ -226,7 +242,7 @@ namespace RhythmHeavenMania.Games.KarateMan
public void Hit4(float beat) public void Hit4(float beat)
{ {
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("karateman/hit", beat), new MultiSound.Sound("karateman/four", beat + 0.5f) }); MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("karateman/four", beat + 0.5f) });
GameObject hit4 = Instantiate(HIT3Ref, this.transform); GameObject hit4 = Instantiate(HIT3Ref, this.transform);
hit4.transform.GetChild(0).GetChild(1).GetComponent<SpriteRenderer>().sprite = Numbers[3]; hit4.transform.GetChild(0).GetChild(1).GetComponent<SpriteRenderer>().sprite = Numbers[3];
BeatAction.New(hit4, new List<BeatAction.Action>() BeatAction.New(hit4, new List<BeatAction.Action>()

View file

@ -258,7 +258,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
} }
else if (ball.highKicked.enabled) else if (ball.highKicked.enabled)
{ {
float normalizedBeat = Conductor.instance.GetPositionFromBeat(ball.highKicked.startBeat, ball.GetHighKickLength(false)); float normalizedBeat = Conductor.instance.GetPositionFromMargin(ball.highKicked.startBeat + ball.GetHighKickLength(false), 1f);
if (!kickPrepare) if (!kickPrepare)
{ {
float normalizedBeatPrepare = Conductor.instance.GetPositionFromBeat(ball.highKicked.startBeat, 1f); float normalizedBeatPrepare = Conductor.instance.GetPositionFromBeat(ball.highKicked.startBeat, 1f);
@ -296,7 +296,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
} }
else if (ball.toe.enabled) else if (ball.toe.enabled)
{ {
float normalizedBeat = Conductor.instance.GetPositionFromBeat(ball.toe.startBeat, ball.GetHighKickLength(true)); float normalizedBeat = Conductor.instance.GetPositionFromMargin(ball.toe.startBeat + ball.GetHighKickLength(true), 1f);
StateCheck(normalizedBeat, !player); StateCheck(normalizedBeat, !player);
CheckIfFall(normalizedBeat); CheckIfFall(normalizedBeat);
@ -346,7 +346,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
private void CheckIfFall(float normalizedBeat) private void CheckIfFall(float normalizedBeat)
{ {
if (normalizedBeat > 1.05f && !GameManager.instance.autoplay) if (normalizedBeat > Minigame.LateTime() && !GameManager.instance.autoplay)
{ {
Jukebox.PlayOneShotGame("spaceSoccer/missNeutral"); Jukebox.PlayOneShotGame("spaceSoccer/missNeutral");
ball = null; ball = null;