diff --git a/Assets/Script/PlayMode/MicPlayer.cs b/Assets/Script/PlayMode/MicPlayer.cs index 98cbc06ca..5501282b6 100644 --- a/Assets/Script/PlayMode/MicPlayer.cs +++ b/Assets/Script/PlayMode/MicPlayer.cs @@ -95,57 +95,65 @@ private void Start() { // Start mics bool hasMic = false; foreach (var player in PlayerManager.players) { - if (player.inputStrategy is MicInputStrategy micStrategy) { - // Skip if the player hasn't assigned a mic - if (micStrategy.microphoneIndex == -1 && !micStrategy.botMode) { - continue; - } + // Skip people who are sitting out + if (player.chosenInstrument != "vocals" && player.chosenInstrument != "harmVocals") { + continue; + } + + // Skip over non-mic strategy players + if (player.inputStrategy is not MicInputStrategy micStrategy) { + continue; + } - hasMic = true; + // Skip if the player hasn't assigned a mic + if (micStrategy.microphoneIndex == -1 && !micStrategy.botMode) { + continue; + } - // Spawn needle - var needle = Instantiate(needlePrefab, transform); - needle.transform.localPosition = needlePrefab.transform.position; + hasMic = true; - // Spawn var - var bar = Instantiate(barPrefab, barContainer); - bar.transform.localPosition = new(0f, 0f, 0.8f - (barContainer.childCount - 1) * 0.225f); + // Spawn needle + var needle = Instantiate(needlePrefab, transform); + needle.transform.localPosition = needlePrefab.transform.position; - // Create player info - var groups = needle.GetComponentsInChildren(); - var playerInfo = new PlayerInfo { - player = player, + // Spawn var + var bar = Instantiate(barPrefab, barContainer); + bar.transform.localPosition = new(0f, 0f, 0.8f - (barContainer.childCount - 1) * 0.225f); - needle = needle.transform, - needleModel = needle.GetComponentInChildren().gameObject, - nonActiveParticles = groups[0], - activeParticles = groups[1], + // Create player info + var groups = needle.GetComponentsInChildren(); + var playerInfo = new PlayerInfo { + player = player, - barMesh = bar.GetComponent() - }; + needle = needle.transform, + needleModel = needle.GetComponentInChildren().gameObject, + nonActiveParticles = groups[0], + activeParticles = groups[1], - // Add to players - micInputs.Add(playerInfo); - - if (!micStrategy.botMode) { - // Add child dummy audio source (for mic input reading) - var go = new GameObject(); - go.transform.parent = transform; - var audio = go.AddComponent(); - dummyAudioSources.Add(micStrategy, audio); - audio.outputAudioMixerGroup = silentMixerGroup; - audio.loop = true; - - // Start the mic! - var micName = Microphone.devices[micStrategy.microphoneIndex]; - audio.clip = Microphone.Start(micName, true, 1, AudioSettings.outputSampleRate); - - // Wait for the mic to start, then start the audio - while (Microphone.GetPosition(micName) <= 0) { - // This loop is weird, but it works. - } - audio.Play(); + barMesh = bar.GetComponent() + }; + + // Add to players + micInputs.Add(playerInfo); + + if (!micStrategy.botMode) { + // Add child dummy audio source (for mic input reading) + var go = new GameObject(); + go.transform.parent = transform; + var audio = go.AddComponent(); + dummyAudioSources.Add(micStrategy, audio); + audio.outputAudioMixerGroup = silentMixerGroup; + audio.loop = true; + + // Start the mic! + var micName = Microphone.devices[micStrategy.microphoneIndex]; + audio.clip = Microphone.Start(micName, true, 1, AudioSettings.outputSampleRate); + + // Wait for the mic to start, then start the audio + while (Microphone.GetPosition(micName) <= 0) { + // This loop is weird, but it works. } + audio.Play(); } } diff --git a/Assets/Script/PlayMode/Play.cs b/Assets/Script/PlayMode/Play.cs index 7f42a01f0..96dacaba8 100644 --- a/Assets/Script/PlayMode/Play.cs +++ b/Assets/Script/PlayMode/Play.cs @@ -90,6 +90,11 @@ private IEnumerator StartSong() { // Spawn tracks int i = 0; foreach (var player in PlayerManager.players) { + if (player.chosenInstrument == null) { + // Skip players that are sitting out + continue; + } + string trackPath = player.inputStrategy.GetTrackPath(); if (trackPath == null) { diff --git a/Assets/Script/UI/DifficultySelect.cs b/Assets/Script/UI/DifficultySelect.cs index e99e70110..5f1135286 100644 --- a/Assets/Script/UI/DifficultySelect.cs +++ b/Assets/Script/UI/DifficultySelect.cs @@ -138,16 +138,28 @@ private void Next() { var player = PlayerManager.players[playerIndex]; if (state == State.INSTRUMENT) { - player.chosenInstrument = instruments[selected]; - UpdateDifficulty(); + if (selected >= instruments.Length) { + player.chosenInstrument = null; + IncreasePlayerIndex(); + } else { + player.chosenInstrument = instruments[selected]; + UpdateDifficulty(); + } } else if (state == State.DIFFICULTY) { player.chosenDifficulty = (Difficulty) selected; IncreasePlayerIndex(); } else if (state == State.VOCALS) { - foreach (var p in PlayerManager.players) { - p.chosenInstrument = selected == 0 ? "vocals" : "harmVocals"; + if (selected == 1) { + foreach (var p in PlayerManager.players) { + p.chosenInstrument = null; + } + IncreasePlayerIndex(); + } else { + foreach (var p in PlayerManager.players) { + p.chosenInstrument = selected == 0 ? "vocals" : "harmVocals"; + } + UpdateVocalDifficulties(); } - UpdateVocalDifficulties(); } else if (state == State.VOCALS_DIFFICULTY) { foreach (var p in PlayerManager.players) { p.chosenDifficulty = (Difficulty) selected; @@ -156,8 +168,6 @@ private void Next() { // Skip over any MicInputStrategy's playerIndex = -1; IncreasePlayerIndex(); - - UpdateInstrument(); } } @@ -210,7 +220,7 @@ private void UpdateInstrument() { // Get allowed instruments var allowedInstruments = player.inputStrategy.GetAllowedInstruments(); - optionCount = allowedInstruments.Length; + optionCount = allowedInstruments.Length + 1; // Add to options string[] ops = new string[6]; @@ -231,13 +241,14 @@ private void UpdateInstrument() { _ => "Unknown" }; } + ops[allowedInstruments.Length] = "Sit Out"; // Set text and sprites for (int i = 0; i < 6; i++) { options[i].SetText(ops[i]); options[i].SetSelected(false); - if (ops[i] != null) { + if (i < instruments.Length) { var sprite = Addressables.LoadAssetAsync($"FontSprites[{instruments[i]}]").WaitForCompletion(); options[i].SetImage(sprite); } @@ -275,10 +286,10 @@ private void UpdateVocalOptions() { state = State.VOCALS; - optionCount = 1; + optionCount = 2; string[] ops = { "Solo", - null, + "Sit Out (All Vocals)", null, null, null, @@ -288,6 +299,11 @@ private void UpdateVocalOptions() { for (int i = 0; i < 6; i++) { options[i].SetText(ops[i]); options[i].SetSelected(false); + + if (i == 0) { + var sprite = Addressables.LoadAssetAsync("FontSprites[vocals]").WaitForCompletion(); + options[i].SetImage(sprite); + } } selected = 0; diff --git a/Assets/Script/UI/ScoreSection.cs b/Assets/Script/UI/ScoreSection.cs index d6c43249a..46c2a16c0 100644 --- a/Assets/Script/UI/ScoreSection.cs +++ b/Assets/Script/UI/ScoreSection.cs @@ -19,6 +19,12 @@ public enum ScoreType { private List text; public void SetScore(PlayerManager.Player player, ScoreType type) { + if (player.chosenInstrument == null) { + playerName.text = player.DisplayName; + text[0].text = "Sat Out"; + return; + } + playerName.text = $" {player.DisplayName}"; if (!player.lastScore.HasValue) {