diff --git a/Scripts/Game/Game.cs b/Scripts/Game/Game.cs index 3ac6e31..fa722b5 100644 --- a/Scripts/Game/Game.cs +++ b/Scripts/Game/Game.cs @@ -4,8 +4,10 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UIElements; +using System.Linq; using UITypes; +using BangerTypes; public class Game : MonoBehaviour { @@ -19,6 +21,9 @@ public class Game : MonoBehaviour string totalDuration; bool repeatRoutine = true; + Song song = null; + + Note[] activeNotes; void Awake() { @@ -35,6 +40,21 @@ public class Game : MonoBehaviour menu.GameElem.UpdateVisualizers(specData, bassStrength); UpdateTimestamp(); + GetNotes(); + } + + public void GetNotes() + { + float timestamp = manager.source.time; + + activeNotes = song.Notes.Where(note => note.t >= timestamp && timestamp + 1f <= note.t).ToArray(); + + if(activeNotes.Length > 0) + { + Debug.Log("Found some notes"); + } + + menu.GameElem.UpdateNotes(activeNotes); } IEnumerator GameLoop() @@ -48,6 +68,7 @@ public class Game : MonoBehaviour public void LoadSong(SongEntry song) { + this.song = song.Song; totalDuration = song.Song.Duration; manager.source.clip = song.Song.Clip; diff --git a/Scripts/UI Types/GameElement.cs b/Scripts/UI Types/GameElement.cs index da86f31..4f00bcb 100644 --- a/Scripts/UI Types/GameElement.cs +++ b/Scripts/UI Types/GameElement.cs @@ -7,6 +7,7 @@ using Unity.VisualScripting; using UnityEngine; using UnityEngine.UIElements; +using BangerTypes; namespace UITypes { @@ -30,6 +31,11 @@ namespace UITypes private VisualElement upUpcomingColumn; public VisualElement downUpcomingColumn; + private bool leftActive = false; + private bool rightActive = false; + private bool downActive = false; + private bool upActive = false; + private Label score; private Label songTime; @@ -97,6 +103,19 @@ namespace UITypes songTime.text = time; } + public void UpdateNotes(Note[] notes) + { + leftActive = notes.Where(note => note.a == "left").Count() > 0; + rightActive = notes.Where(note => note.a == "right").Count() > 0; + upActive = notes.Where(note => note.a == "up").Count() > 0; + downActive = notes.Where(note => note.a == "down").Count() > 0; + + leftUpcomingColumn.EnableInClassList("ColumnActive", leftActive); + rightUpcomingColumn.EnableInClassList("ColumnActive", rightActive); + downUpcomingColumn.EnableInClassList("ColumnActive", downActive); + upUpcomingColumn.EnableInClassList("ColumnActive", upActive); + } + void OnKeyDown(KeyDownEvent ev) { if (ev.keyCode == KeyCode.Escape) diff --git a/UI/Game.uss b/UI/Game.uss index a08d108..dba5a6f 100644 --- a/UI/Game.uss +++ b/UI/Game.uss @@ -77,4 +77,8 @@ #GameBackgroundImageRight { background-image: url('project://database/Assets/Images/right.png'); margin-left: 35%; +} + +.ColumnActive { + background-color: green; } \ No newline at end of file