Skip to content

Commit

Permalink
Setlist now clears correctly
Browse files Browse the repository at this point in the history
* Setlist now properly clears on finish
* Added "next up" text to results screen if there is more than one song remaining in the setlist
* Moved a few setlist-related methods around
  • Loading branch information
EscapeNumber001 committed Apr 16, 2023
1 parent dbf53d5 commit 5df9cd6
Show file tree
Hide file tree
Showing 5 changed files with 1,375 additions and 25 deletions.
137 changes: 137 additions & 0 deletions Assets/Scenes/MenuScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -6540,6 +6540,141 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 580206577}
m_CullTransparentMesh: 1
--- !u!1 &588690936
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 588690937}
- component: {fileID: 588690939}
- component: {fileID: 588690938}
m_Layer: 5
m_Name: NextSongInSetlistHint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &588690937
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 588690936}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1149865194}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0.00048828, y: -169}
m_SizeDelta: {x: 800, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &588690938
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 588690936}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 'Next: Song - Artist (5/6)'
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 34
m_fontSizeBase: 34
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &588690939
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 588690936}
m_CullTransparentMesh: 1
--- !u!1 &593585161
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -11799,6 +11934,7 @@ RectTransform:
- {fileID: 2026357492}
- {fileID: 276903677}
- {fileID: 1015145811}
- {fileID: 588690937}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand All @@ -11822,6 +11958,7 @@ MonoBehaviour:
scoreSection: {fileID: 835764517238708903, guid: a44758e52d42cb649b71664c3b516e09,
type: 3}
header: {fileID: 2026357490}
nextUp: {fileID: 588690938}
scoreContainer: {fileID: 1816306048}
--- !u!1001 &1151438760
PrefabInstance:
Expand Down
31 changes: 31 additions & 0 deletions Assets/Script/PlayMode/Play.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public static Play Instance {
public const float SONG_START_OFFSET = 1f;

public static SongInfo song = null;

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

public delegate void BeatAction();
public static event BeatAction BeatEvent;
Expand Down Expand Up @@ -359,6 +363,33 @@ private void UpdateAudio(string[] names, string[] audio) {
}
}

public static void AddSongToSetlist(SongInfo song)
{
setlist.Add(song);
}

public static void StartSetlist()
{
song = setlist[0];
setlistSize = setlist.Count;
setlistCurrentSongIndex = 0;
GameManager.Instance.LoadScene(SceneIndex.PLAY);
}

public static void ContinueSetlist()
{
setlistCurrentSongIndex++;
song = setlist[Play.setlistCurrentSongIndex];
GameManager.Instance.LoadScene(SceneIndex.PLAY);
}

public static void EndSetlist()
{
setlistSize = 0;
setlistCurrentSongIndex = 0;
setlist.Clear();
}

public void Exit() {
// Dispose of all audio
foreach (var audioHandler in audioHandlers) {
Expand Down
25 changes: 11 additions & 14 deletions Assets/Script/UI/DifficultySelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private void IncreasePlayerIndex() {
StartSong();
} else
{
AddSongToSetlist();
Play.AddSongToSetlist(MainMenu.Instance.chosenSong);
MainMenu.Instance.ShowSongSelect();
}

Expand All @@ -214,23 +214,20 @@ private void IncreasePlayerIndex() {
}
}

public void UpdateSetlistMode() {
isSetlistMode = GameObject.Find("Setlist Enabled Checkbox").GetComponent<Toggle>().isOn;
}

private void AddSongToSetlist() {
Play.setlist.Add(MainMenu.Instance.chosenSong);
}

private void StartSong() {
private void StartSong()
{
Play.song = MainMenu.Instance.chosenSong;
GameManager.Instance.LoadScene(SceneIndex.PLAY);
}

public void StartSetlist() {
Play.song = Play.setlist[0];
GameManager.Instance.LoadScene(SceneIndex.PLAY);
}
public static void StartSetlist()
{
Play.StartSetlist();
}

public void UpdateSetlistMode() {
isSetlistMode = GameObject.Find("Setlist Enabled Checkbox").GetComponent<Toggle>().isOn;
}

private void UpdateInstrument() {
// Header
Expand Down
21 changes: 20 additions & 1 deletion Assets/Script/UI/PostSong.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public class PostSong : MonoBehaviour {

[SerializeField]
private TextMeshProUGUI header;

[SerializeField]
private TextMeshProUGUI nextUp;

[SerializeField]
private Transform scoreContainer;

Expand All @@ -22,7 +26,14 @@ private void OnEnable() {
header.text = $"{Play.song.SongName} - {Play.song.artistName}";
} else {
header.text = $"{Play.song.SongName} ({Play.speed * 100}% speed) - {Play.song.artistName}";
}
}

if (Play.setlistCurrentSongIndex < Play.setlistSize - 1) {
var nextSong = Play.setlist[Play.setlistCurrentSongIndex + 1];
nextUp.text = $"Next up: {nextSong.SongName} - {nextSong.artistName}";
} else {
nextUp.text = "";
}

// Create a score to push

Expand Down Expand Up @@ -104,6 +115,14 @@ private void OnDisable() {
foreach (var player in PlayerManager.players) {
player.inputStrategy.GenericNavigationEvent -= OnGenericNavigation;
}

if (Play.setlistCurrentSongIndex < Play.setlistSize)
{
Play.ContinueSetlist();
} else
{
Play.EndSetlist();
}
}

private void Update() {
Expand Down
Loading

0 comments on commit 5df9cd6

Please sign in to comment.