Prep for main gameplay
This commit is contained in:
parent
079c01b01c
commit
e56da61974
@ -4,8 +4,10 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
using UnityEngine.UIElements;
|
using UnityEngine.UIElements;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
using UITypes;
|
using UITypes;
|
||||||
|
using BangerTypes;
|
||||||
|
|
||||||
public class Game : MonoBehaviour
|
public class Game : MonoBehaviour
|
||||||
{
|
{
|
||||||
@ -19,6 +21,9 @@ public class Game : MonoBehaviour
|
|||||||
string totalDuration;
|
string totalDuration;
|
||||||
bool repeatRoutine = true;
|
bool repeatRoutine = true;
|
||||||
|
|
||||||
|
Song song = null;
|
||||||
|
|
||||||
|
Note[] activeNotes;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
@ -35,6 +40,21 @@ public class Game : MonoBehaviour
|
|||||||
menu.GameElem.UpdateVisualizers(specData, bassStrength);
|
menu.GameElem.UpdateVisualizers(specData, bassStrength);
|
||||||
|
|
||||||
UpdateTimestamp();
|
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()
|
IEnumerator GameLoop()
|
||||||
@ -48,6 +68,7 @@ public class Game : MonoBehaviour
|
|||||||
|
|
||||||
public void LoadSong(SongEntry song)
|
public void LoadSong(SongEntry song)
|
||||||
{
|
{
|
||||||
|
this.song = song.Song;
|
||||||
totalDuration = song.Song.Duration;
|
totalDuration = song.Song.Duration;
|
||||||
|
|
||||||
manager.source.clip = song.Song.Clip;
|
manager.source.clip = song.Song.Clip;
|
||||||
|
@ -7,6 +7,7 @@ using Unity.VisualScripting;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UIElements;
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
using BangerTypes;
|
||||||
|
|
||||||
namespace UITypes
|
namespace UITypes
|
||||||
{
|
{
|
||||||
@ -30,6 +31,11 @@ namespace UITypes
|
|||||||
private VisualElement upUpcomingColumn;
|
private VisualElement upUpcomingColumn;
|
||||||
public VisualElement downUpcomingColumn;
|
public VisualElement downUpcomingColumn;
|
||||||
|
|
||||||
|
private bool leftActive = false;
|
||||||
|
private bool rightActive = false;
|
||||||
|
private bool downActive = false;
|
||||||
|
private bool upActive = false;
|
||||||
|
|
||||||
private Label score;
|
private Label score;
|
||||||
private Label songTime;
|
private Label songTime;
|
||||||
|
|
||||||
@ -97,6 +103,19 @@ namespace UITypes
|
|||||||
songTime.text = time;
|
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)
|
void OnKeyDown(KeyDownEvent ev)
|
||||||
{
|
{
|
||||||
if (ev.keyCode == KeyCode.Escape)
|
if (ev.keyCode == KeyCode.Escape)
|
||||||
|
@ -77,4 +77,8 @@
|
|||||||
#GameBackgroundImageRight {
|
#GameBackgroundImageRight {
|
||||||
background-image: url('project://database/Assets/Images/right.png');
|
background-image: url('project://database/Assets/Images/right.png');
|
||||||
margin-left: 35%;
|
margin-left: 35%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ColumnActive {
|
||||||
|
background-color: green;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user