From c018f1c5600570cf5b1977b64dc744fbec0ffe41 Mon Sep 17 00:00:00 2001 From: Carson Kompon Date: Fri, 11 Mar 2022 20:54:05 -0500 Subject: [PATCH] Mr. Upbeat now starts on the go no matter what --- Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs | 15 ++++++++++++++- Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs b/Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs index 00e391e0..233954e8 100644 --- a/Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs +++ b/Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; using System; using Starpelly; @@ -20,6 +21,8 @@ namespace RhythmHeavenMania.Games.MrUpbeat public bool canGo = false; public int beatCount = 0; + public float beatOffset = 0f; + public static MrUpbeat instance; private void Awake() @@ -34,6 +37,14 @@ namespace RhythmHeavenMania.Games.MrUpbeat SetInterval(0); var pos = Conductor.instance.songPositionInBeats; StartCoroutine(Upbeat(pos - Mathf.Round(pos))); + + List gos = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "mrUpbeat/go").Select(c => c.beat).ToList(); + + if (gos.Count > 0) + { + var nextInterval = gos.IndexOf(Mathp.GetClosestInList(gos, Conductor.instance.songPositionInBeats)); + beatOffset = gos[nextInterval]; + } } private void Update() @@ -53,7 +64,8 @@ namespace RhythmHeavenMania.Games.MrUpbeat if (canGo) { - metronome.transform.eulerAngles = new Vector3(0, 0, 270 - Mathf.Cos(Mathf.PI * Conductor.instance.songPositionInBeats) * 75); + var songPos = Conductor.instance.songPositionInBeats - beatOffset; + metronome.transform.eulerAngles = new Vector3(0, 0, 270 - Mathf.Cos(Mathf.PI * songPos) * 75); } if (Conductor.instance.ReportBeat(ref beat.lastReportedBeat)) @@ -121,6 +133,7 @@ namespace RhythmHeavenMania.Games.MrUpbeat _beat.SetActive(true); UpbeatStep s = _beat.GetComponent(); s.startBeat = beat; + s.beatOffset = beatOffset; } private IEnumerator Upbeat(float offset = 0) diff --git a/Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs b/Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs index f0b1d1f0..f6591ebc 100644 --- a/Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs +++ b/Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs @@ -12,6 +12,7 @@ namespace RhythmHeavenMania.Games.MrUpbeat { public float startBeat; private bool passedFirst = false; + public float beatOffset = 0; private void Start() { @@ -27,7 +28,7 @@ namespace RhythmHeavenMania.Games.MrUpbeat { if (Conductor.instance.GetPositionFromBeat(startBeat, 0.35f) >= 1 && !passedFirst) { - if(MrUpbeat.instance.man.stepTimes % 2 != startBeat % 2) + if(MrUpbeat.instance.man.stepTimes % 2 != Math.Round(startBeat - beatOffset) % 2) Hit(false); passedFirst = true; }