HeavenStudioPlus/Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs

89 lines
2.5 KiB
C#
Raw Normal View History

2022-03-04 20:47:40 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Starpelly;
using RhythmHeavenMania.Util;
namespace RhythmHeavenMania.Games.MrUpbeat
{
public class MrUpbeat : Minigame
{
[Header("References")]
public GameObject metronome;
public UpbeatMan man;
2022-03-05 03:10:10 +00:00
public GameEvent beat = new GameEvent();
public GameEvent offbeat = new GameEvent();
public bool canGo = false;
2022-03-05 03:10:10 +00:00
private int beatCount = 0;
2022-03-04 20:47:40 +00:00
public static MrUpbeat instance;
private void Awake()
{
instance = this;
}
private void Update()
{
2022-03-05 03:10:10 +00:00
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++)
{
if ((gos[i].beat - 0.15f) <= Conductor.instance.songPositionInBeats && (gos[i].beat + gos[i].length) - 0.15f > Conductor.instance.songPositionInBeats)
{
canGo = true;
break;
} else
{
canGo = false;
}
}
2022-03-05 03:10:10 +00:00
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)
{
2022-03-05 03:10:10 +00:00
beatCount = 0;
offbeat.startBeat = beat;
man.targetBeat = beat + 320f;
man.Idle();
}
public void Go(float beat)
{
beatCount = 0;
}
2022-03-04 20:47:40 +00:00
}
}