Skip to content

Commit

Permalink
Implemented speed changes into setlists
Browse files Browse the repository at this point in the history
  • Loading branch information
EscapeNumber001 committed Apr 16, 2023
1 parent 5df9cd6 commit 4ada28a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 7 additions & 2 deletions Assets/Script/PlayMode/Play.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static Play Instance {

// TODO: Store song speeds in setlist
public static List<SongInfo> setlist = new();
public static List<float> setlistSongSpeeds = new();
public static int setlistCurrentSongIndex = 0;
public static int setlistSize = 0;

Expand Down Expand Up @@ -363,9 +364,10 @@ private void UpdateAudio(string[] names, string[] audio) {
}
}

public static void AddSongToSetlist(SongInfo song)
public static void AddSongToSetlist(SongInfo song, float speed)
{
setlist.Add(song);
setlistSongSpeeds.Add(speed);
}

public static void StartSetlist()
Expand All @@ -379,15 +381,18 @@ public static void StartSetlist()
public static void ContinueSetlist()
{
setlistCurrentSongIndex++;
song = setlist[Play.setlistCurrentSongIndex];
song = setlist[setlistCurrentSongIndex];
speed = setlistSongSpeeds[setlistCurrentSongIndex];
GameManager.Instance.LoadScene(SceneIndex.PLAY);
}

public static void EndSetlist()
{
Debug.Log("Setlist finished");
setlistSize = 0;
setlistCurrentSongIndex = 0;
setlist.Clear();
setlistSongSpeeds.Clear();
}

public void Exit() {
Expand Down
9 changes: 5 additions & 4 deletions Assets/Script/UI/DifficultySelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,19 @@ private void IncreasePlayerIndex() {

if (playerIndex >= PlayerManager.players.Count) {
// Set speed
Play.speed = float.Parse(speedInput.text, CultureInfo.InvariantCulture);
if (Play.speed <= 0f) {
Play.speed = 1f;
var speed = float.Parse(speedInput.text, CultureInfo.InvariantCulture);
if (speed <= 0f) {
speed = 1f;
}

// Play song (or download then play)

if (!isSetlistMode) {
Play.speed = speed;
StartSong();
} else
{
Play.AddSongToSetlist(MainMenu.Instance.chosenSong);
Play.AddSongToSetlist(MainMenu.Instance.chosenSong, speed);
MainMenu.Instance.ShowSongSelect();
}

Expand Down

0 comments on commit 4ada28a

Please sign in to comment.