General code cleanup

This commit is contained in:
Starpelly
2021-12-22 21:28:05 -05:00
parent 575e47e384
commit 1a7b1b7e07
10 changed files with 686 additions and 442 deletions

View File

@ -6,7 +6,7 @@ namespace RhythmHeavenMania
[Serializable]
public class Beatmap
{
public double bpm;
public float bpm;
public List<Entity> entities;
[Serializable]
@ -14,6 +14,7 @@ namespace RhythmHeavenMania
{
public float beat;
public int track;
public float length;
public string datamodel;
public object Clone()

View File

@ -104,6 +104,12 @@ namespace RhythmHeavenMania
return final;
}
public void SetBpm(float bpm)
{
this.songBpm = bpm;
secPerBeat = 60f / songBpm;
}
public bool InThreshold(float beat)
{
//Check if the beat sent falls within beatThreshold

View File

@ -66,6 +66,10 @@ namespace RhythmHeavenMania
new GameAction("prepare", delegate { ForkLifter.instance.ForkLifterHand.Prepare(); }),
new GameAction("gulp", delegate { ForkLifterPlayer.instance.Eat(); }),
new GameAction("sigh", delegate { Jukebox.PlayOneShot("sigh"); })
}),
new MiniGame("clappyTrio", new List<GameAction>()
{
new GameAction("clap", delegate { Debug.Log("bruh"); }, true ),
})
};
@ -93,7 +97,7 @@ namespace RhythmHeavenMania
private void Update()
{
if (GameManager.instance.currentEvent > 0 && GameManager.instance.currentEvent < GameManager.instance.Beatmap.entities.Count)
if (GameManager.instance.currentEvent >= 0 && GameManager.instance.currentEvent < GameManager.instance.Beatmap.entities.Count)
currentBeat = GameManager.instance.Beatmap.entities[GameManager.instance.currentEvent].beat;
}

View File

@ -34,16 +34,17 @@ namespace RhythmHeavenMania
SortEventsList();
string json = txt.text;
Beatmap.entities = JsonConvert.DeserializeObject<List<Beatmap.Entity>>(json);
Beatmap = JsonConvert.DeserializeObject<Beatmap>(json);
SortEventsList();
StartCoroutine(Begin());
GlobalGameManager.Init();
eventCaller = GetComponent<EventCaller>();
eventCaller.Init();
Conductor.instance.SetBpm(Beatmap.bpm);
StartCoroutine(Begin());
}
private IEnumerator Begin()