Slightly functional Mr. Upbeat

This commit is contained in:
Carson Kompon
2022-03-04 22:10:10 -05:00
parent 063c144e44
commit 8b2ee6cac5
6 changed files with 275 additions and 36 deletions

View File

@ -14,9 +14,10 @@ namespace RhythmHeavenMania.Games.MrUpbeat
public GameObject metronome;
public UpbeatMan man;
public float nextBeat;
public GameEvent beat = new GameEvent();
public GameEvent offbeat = new GameEvent();
public bool canGo = false;
private int beatCount = 0;
public static MrUpbeat instance;
@ -27,6 +28,11 @@ namespace RhythmHeavenMania.Games.MrUpbeat
private void Update()
{
if (canGo)
metronome.transform.eulerAngles = new Vector3(0, 0, 270 - Mathf.Cos(Mathf.PI * Conductor.instance.songPositionInBeats) * 75);
//else
// metronome.transform.eulerAngles = new Vector3(0, 0, 200);
List<Beatmap.Entity> gos = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "mrUpbeat/go");
for(int i=0; i<gos.Count; i++)
{
@ -40,13 +46,42 @@ namespace RhythmHeavenMania.Games.MrUpbeat
}
}
float normalizedBeat = Conductor.instance.GetPositionFromBeat(nextBeat, 0.5f);
//StateCheck(normalizedBeat);
if (Conductor.instance.ReportBeat(ref beat.lastReportedBeat) && canGo)
{
if(beatCount % 2 == 0)
Jukebox.PlayOneShotGame("mrUpbeat/metronomeRight");
else
Jukebox.PlayOneShotGame("mrUpbeat/metronomeLeft");
beatCount++;
}
if (Conductor.instance.ReportBeat(ref offbeat.lastReportedBeat, 0.25f, true))
{
man.Blip();
if(canGo) man.targetBeat = offbeat.lastReportedBeat + 1f;
}
}
public override void OnGameSwitch()
{
base.OnGameSwitch();
canGo = false;
man.stepTimes = 0;
SetInterval(0);
}
public void SetInterval(float beat)
{
nextBeat = beat;
beatCount = 0;
offbeat.startBeat = beat;
man.targetBeat = beat + 320f;
man.Idle();
}
public void Go(float beat)
{
beatCount = 0;
}