From d3e2d425bfef384b30ae67723e2542fb35b599f9 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 7 Mar 2025 09:26:54 +0100 Subject: [PATCH] Implemented getting and setting high scores from server --- .../DungeonData/01_30x30_5_monster.asset | 3 +- .../DungeonData/02_30x30_5_monster.asset | 3 +- .../DungeonData/03_30x30_5_monster.asset | 3 +- .../Scenes/Dungeons/01_30x30_5_monster.unity | 14 ++ .../Scenes/Dungeons/02_30x30_5_monster.unity | 14 ++ .../Scenes/Dungeons/03_30x30_5_monster.unity | 14 ++ PuzzleGameProject/Assets/Scenes/Start.unity | 48 ++++++- .../Scripts/DungeonSelection/DungeonData.cs | 3 +- .../DungeonSelection/DungeonSelector.cs | 75 ++++++++++- .../Scripts/DungeonSelection/GameEvents.cs | 2 +- .../Scripts/DungeonSelection/UIEvents.cs | 1 + .../Assets/Scripts/LeaveDungeonHandler.cs | 6 +- PuzzleGameProject/Assets/Scripts/Scores.meta | 8 ++ .../Assets/Scripts/Scores/ScoreManager.cs | 122 ++++++++++++++++++ .../Scripts/Scores/ScoreManager.cs.meta | 2 + .../Scripts/UI/DungeonSelectMenuController.cs | 43 +++++- .../Assets/UI/DungeonSelect.uxml | 2 +- 17 files changed, 346 insertions(+), 17 deletions(-) create mode 100644 PuzzleGameProject/Assets/Scripts/Scores.meta create mode 100644 PuzzleGameProject/Assets/Scripts/Scores/ScoreManager.cs create mode 100644 PuzzleGameProject/Assets/Scripts/Scores/ScoreManager.cs.meta diff --git a/PuzzleGameProject/Assets/GameData/DungeonData/01_30x30_5_monster.asset b/PuzzleGameProject/Assets/GameData/DungeonData/01_30x30_5_monster.asset index 50e68a9..f7891c9 100644 --- a/PuzzleGameProject/Assets/GameData/DungeonData/01_30x30_5_monster.asset +++ b/PuzzleGameProject/Assets/GameData/DungeonData/01_30x30_5_monster.asset @@ -12,7 +12,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b94e2e73105498fac9021dca1250c4b, type: 3} m_Name: 01_30x30_5_monster m_EditorClassIdentifier: - DungeonName: Abomination Vault + Name: Abomination Vaults + Id: 1 Thumbnail: {fileID: 21300000, guid: 64f388d4f370f6d4db97a9fd30afb6a9, type: 3} SceneName: 01_30x30_5_monster WinMessage: Now you may return to Otari a hero! diff --git a/PuzzleGameProject/Assets/GameData/DungeonData/02_30x30_5_monster.asset b/PuzzleGameProject/Assets/GameData/DungeonData/02_30x30_5_monster.asset index d419f35..ee94c23 100644 --- a/PuzzleGameProject/Assets/GameData/DungeonData/02_30x30_5_monster.asset +++ b/PuzzleGameProject/Assets/GameData/DungeonData/02_30x30_5_monster.asset @@ -12,7 +12,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b94e2e73105498fac9021dca1250c4b, type: 3} m_Name: 02_30x30_5_monster m_EditorClassIdentifier: - DungeonName: Tomb of Annihilation + Name: Tomb of Annihilation + Id: 2 Thumbnail: {fileID: 21300000, guid: 2d9ec4bca04e08448924650a381b2041, type: 3} SceneName: 02_30x30_5_monster WinMessage: The curse is broken, but the scars remain diff --git a/PuzzleGameProject/Assets/GameData/DungeonData/03_30x30_5_monster.asset b/PuzzleGameProject/Assets/GameData/DungeonData/03_30x30_5_monster.asset index 7c674bd..1808b37 100644 --- a/PuzzleGameProject/Assets/GameData/DungeonData/03_30x30_5_monster.asset +++ b/PuzzleGameProject/Assets/GameData/DungeonData/03_30x30_5_monster.asset @@ -12,7 +12,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b94e2e73105498fac9021dca1250c4b, type: 3} m_Name: 03_30x30_5_monster m_EditorClassIdentifier: - DungeonName: Descent Into Avernus + Name: Descent into Avernus + Id: 3 Thumbnail: {fileID: 21300000, guid: ef152ae0fa820c2429781e262a724da4, type: 3} SceneName: 03_30x30_5_monster WinMessage: You killed them all... but at what cost? diff --git a/PuzzleGameProject/Assets/Scenes/Dungeons/01_30x30_5_monster.unity b/PuzzleGameProject/Assets/Scenes/Dungeons/01_30x30_5_monster.unity index 44b6189..9fe1428 100644 --- a/PuzzleGameProject/Assets/Scenes/Dungeons/01_30x30_5_monster.unity +++ b/PuzzleGameProject/Assets/Scenes/Dungeons/01_30x30_5_monster.unity @@ -8037,6 +8037,7 @@ GameObject: - component: {fileID: 1417835872} - component: {fileID: 1417835871} - component: {fileID: 1417835873} + - component: {fileID: 1417835874} m_Layer: 0 m_Name: GameManager m_TagString: Untagged @@ -8089,6 +8090,19 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: dungeonData: {fileID: 11400000, guid: acaf9288bf3a20c41a924587743eba81, type: 2} + scoreManager: {fileID: 1417835874} +--- !u!114 &1417835874 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1417835870} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c4a5bac4f66aaf84991ec68d8f2a4705, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1425310156 GameObject: m_ObjectHideFlags: 0 diff --git a/PuzzleGameProject/Assets/Scenes/Dungeons/02_30x30_5_monster.unity b/PuzzleGameProject/Assets/Scenes/Dungeons/02_30x30_5_monster.unity index 75183f2..dde0a0d 100644 --- a/PuzzleGameProject/Assets/Scenes/Dungeons/02_30x30_5_monster.unity +++ b/PuzzleGameProject/Assets/Scenes/Dungeons/02_30x30_5_monster.unity @@ -8989,6 +8989,7 @@ GameObject: - component: {fileID: 1417835872} - component: {fileID: 1417835871} - component: {fileID: 1417835873} + - component: {fileID: 1417835874} m_Layer: 0 m_Name: GameManager m_TagString: Untagged @@ -9041,6 +9042,19 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: dungeonData: {fileID: 11400000, guid: 74afdc22b525eeb43935ac56a2da2b37, type: 2} + scoreManager: {fileID: 1417835874} +--- !u!114 &1417835874 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1417835870} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c4a5bac4f66aaf84991ec68d8f2a4705, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &1431493912 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/PuzzleGameProject/Assets/Scenes/Dungeons/03_30x30_5_monster.unity b/PuzzleGameProject/Assets/Scenes/Dungeons/03_30x30_5_monster.unity index 152479d..1a8ae3e 100644 --- a/PuzzleGameProject/Assets/Scenes/Dungeons/03_30x30_5_monster.unity +++ b/PuzzleGameProject/Assets/Scenes/Dungeons/03_30x30_5_monster.unity @@ -9440,6 +9440,7 @@ GameObject: - component: {fileID: 1417835872} - component: {fileID: 1417835871} - component: {fileID: 1417835873} + - component: {fileID: 1417835874} m_Layer: 0 m_Name: GameManager m_TagString: Untagged @@ -9492,6 +9493,19 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: dungeonData: {fileID: 11400000, guid: be76377cae8ede04ba4523be6e094f17, type: 2} + scoreManager: {fileID: 1417835874} +--- !u!114 &1417835874 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1417835870} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c4a5bac4f66aaf84991ec68d8f2a4705, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &1426145005 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/PuzzleGameProject/Assets/Scenes/Start.unity b/PuzzleGameProject/Assets/Scenes/Start.unity index d760f15..66cf6bd 100644 --- a/PuzzleGameProject/Assets/Scenes/Start.unity +++ b/PuzzleGameProject/Assets/Scenes/Start.unity @@ -153,6 +153,7 @@ MonoBehaviour: - {fileID: 11400000, guid: acaf9288bf3a20c41a924587743eba81, type: 2} - {fileID: 11400000, guid: 74afdc22b525eeb43935ac56a2da2b37, type: 2} - {fileID: 11400000, guid: be76377cae8ede04ba4523be6e094f17, type: 2} + scoreManager: {fileID: 2121761225} --- !u!4 &455091938 Transform: m_ObjectHideFlags: 0 @@ -261,7 +262,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &1131314919 MonoBehaviour: m_ObjectHideFlags: 0 @@ -445,6 +446,50 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2121761223 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2121761224} + - component: {fileID: 2121761225} + m_Layer: 0 + m_Name: ScoreManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2121761224 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2121761223} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.773548, y: 1.0709885, z: -0.04651529} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &2121761225 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2121761223} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c4a5bac4f66aaf84991ec68d8f2a4705, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 @@ -454,3 +499,4 @@ SceneRoots: - {fileID: 455091938} - {fileID: 1131314920} - {fileID: 1963856834} + - {fileID: 2121761224} diff --git a/PuzzleGameProject/Assets/Scripts/DungeonSelection/DungeonData.cs b/PuzzleGameProject/Assets/Scripts/DungeonSelection/DungeonData.cs index ede921d..038f8bc 100644 --- a/PuzzleGameProject/Assets/Scripts/DungeonSelection/DungeonData.cs +++ b/PuzzleGameProject/Assets/Scripts/DungeonSelection/DungeonData.cs @@ -6,7 +6,8 @@ namespace DungeonSelection [CreateAssetMenu(fileName = "New Dungeon", menuName = "Dungeon")] public class DungeonData : ScriptableObject { - public string DungeonName; + public string Name; + public int Id; public Sprite Thumbnail; public string SceneName; public string WinMessage; diff --git a/PuzzleGameProject/Assets/Scripts/DungeonSelection/DungeonSelector.cs b/PuzzleGameProject/Assets/Scripts/DungeonSelection/DungeonSelector.cs index 568a79b..4fe790e 100644 --- a/PuzzleGameProject/Assets/Scripts/DungeonSelection/DungeonSelector.cs +++ b/PuzzleGameProject/Assets/Scripts/DungeonSelection/DungeonSelector.cs @@ -1,21 +1,51 @@ using System; +using System.Collections; using System.Collections.Generic; +using Scores; using UnityEngine; using UnityEngine.Serialization; namespace DungeonSelection { + public class DungeonDisplayData + { + public DungeonDisplayData(DungeonData dungeonData, List highScores) + { + DungeonData = dungeonData; + HighScores = highScores; + } + public DungeonData DungeonData; + public List HighScores; + } + + public class ScoreDisplay + { + public ScoreDisplay(string playerName, int score) + { + PlayerName = playerName; + Score = score; + } + + public string PlayerName; + public int Score; + } + public class DungeonSelector : MonoBehaviour { [SerializeField] private DungeonData[] dungeons; + [SerializeField] private ScoreManager scoreManager; private DungeonData _currentlySelectedDungeonData; private int _currentlySelectedDungeonIndex = 0; + private Dictionary> scoresByLevelId = new Dictionary>(); + + private bool _scoresReceived = false; private void OnEnable() { UIEvents.NextDungeonClicked += SelectNextDungeon; UIEvents.PreviousDungeonClicked += SelectPreviousDungeon; UIEvents.EnterDungeonClicked += LoadDungeon; + scoreManager.ScoresRecieved += HandleScoresRecieved; } private void OnDisable() @@ -23,6 +53,7 @@ namespace DungeonSelection UIEvents.NextDungeonClicked -= SelectNextDungeon; UIEvents.PreviousDungeonClicked -= SelectPreviousDungeon; UIEvents.EnterDungeonClicked -= LoadDungeon; + scoreManager.ScoresRecieved -= HandleScoresRecieved; } private void Start() @@ -30,7 +61,18 @@ namespace DungeonSelection GameEvents.DungeonSelectionStarted?.Invoke(); _currentlySelectedDungeonData = dungeons[_currentlySelectedDungeonIndex]; - GameEvents.ShowingDungeon?.Invoke(_currentlySelectedDungeonData); + StartCoroutine(WaitForScoresAndShowDungeon()); + } + + private IEnumerator WaitForScoresAndShowDungeon() + { + while (!_scoresReceived) + { + yield return null; + } + + scoresByLevelId.TryGetValue(_currentlySelectedDungeonData.Id, out var scoreDisplays); + GameEvents.ShowingDungeon?.Invoke(new DungeonDisplayData(_currentlySelectedDungeonData, scoreDisplays ?? new List())); if (_currentlySelectedDungeonIndex == 0) { GameEvents.ShowingFirstDugeon?.Invoke(); @@ -47,7 +89,8 @@ namespace DungeonSelection if (_currentlySelectedDungeonIndex + 1 >= dungeons.Length) return; _currentlySelectedDungeonIndex++; _currentlySelectedDungeonData = dungeons[_currentlySelectedDungeonIndex]; - GameEvents.ShowingDungeon?.Invoke(_currentlySelectedDungeonData); + scoresByLevelId.TryGetValue(_currentlySelectedDungeonData.Id, out var scoreDisplays); + GameEvents.ShowingDungeon?.Invoke(new DungeonDisplayData(_currentlySelectedDungeonData, scoreDisplays ?? new List())); if (_currentlySelectedDungeonIndex == dungeons.Length - 1) { GameEvents.ShowingLastDungeon?.Invoke(); @@ -59,11 +102,37 @@ namespace DungeonSelection if (_currentlySelectedDungeonIndex - 1 < 0) return; _currentlySelectedDungeonIndex--; _currentlySelectedDungeonData = dungeons[_currentlySelectedDungeonIndex]; - GameEvents.ShowingDungeon?.Invoke(_currentlySelectedDungeonData); + scoresByLevelId.TryGetValue(_currentlySelectedDungeonData.Id, out var scoreDisplays); + GameEvents.ShowingDungeon?.Invoke(new DungeonDisplayData(_currentlySelectedDungeonData, scoreDisplays ?? new List())); if (_currentlySelectedDungeonIndex == 0) { GameEvents.ShowingFirstDugeon?.Invoke(); } } + + private void HandleScoresRecieved(ScoreEntry[] scores) + { + scoresByLevelId = new Dictionary>(); + foreach (ScoreEntry score in scores) + { + if (scoresByLevelId.TryGetValue(score.level_id, out var scoresDisplay)) + { + scoresDisplay.Add(new ScoreDisplay(score.player, score.score)); + } + else + { + scoresByLevelId[score.level_id] = new List() + { new ScoreDisplay(score.player, score.score) }; + } + } + + foreach (List scoresDisplay in scoresByLevelId.Values) + { + // Sort highest to lowest + scoresDisplay.Sort((a, b) => b.Score.CompareTo(a.Score)); + } + + _scoresReceived = true; + } } } diff --git a/PuzzleGameProject/Assets/Scripts/DungeonSelection/GameEvents.cs b/PuzzleGameProject/Assets/Scripts/DungeonSelection/GameEvents.cs index 95e1231..7bafb7d 100644 --- a/PuzzleGameProject/Assets/Scripts/DungeonSelection/GameEvents.cs +++ b/PuzzleGameProject/Assets/Scripts/DungeonSelection/GameEvents.cs @@ -8,7 +8,7 @@ namespace DungeonSelection public static Action DungeonSelectionStarted; public static Action ShowingLastDungeon; public static Action ShowingFirstDugeon; - public static Action ShowingDungeon; + public static Action ShowingDungeon; public static Action LoadDungeon; } } \ No newline at end of file diff --git a/PuzzleGameProject/Assets/Scripts/DungeonSelection/UIEvents.cs b/PuzzleGameProject/Assets/Scripts/DungeonSelection/UIEvents.cs index 488e937..1a5d0c4 100644 --- a/PuzzleGameProject/Assets/Scripts/DungeonSelection/UIEvents.cs +++ b/PuzzleGameProject/Assets/Scripts/DungeonSelection/UIEvents.cs @@ -10,5 +10,6 @@ namespace DungeonSelection public static Action EnterDungeonClicked; public static Action CloseRules; public static Action ShowRules; + public static Action GetScores; } } \ No newline at end of file diff --git a/PuzzleGameProject/Assets/Scripts/LeaveDungeonHandler.cs b/PuzzleGameProject/Assets/Scripts/LeaveDungeonHandler.cs index 14fdaa7..dc5d0af 100644 --- a/PuzzleGameProject/Assets/Scripts/LeaveDungeonHandler.cs +++ b/PuzzleGameProject/Assets/Scripts/LeaveDungeonHandler.cs @@ -1,11 +1,15 @@ using System; +using System.Collections; using DungeonSelection; +using Scores; using UnityEngine; using UnityEngine.SceneManagement; public class LeaveDungeonHandler : MonoBehaviour { [SerializeField] private DungeonData dungeonData; + [SerializeField] private ScoreManager scoreManager; + private void OnEnable() { EndGameController.LeaveDungeonClicked += LeaveDungeon; @@ -20,7 +24,7 @@ public class LeaveDungeonHandler : MonoBehaviour private void SaveScore(string name, int score) { - Debug.Log($"{name} | {score}"); + scoreManager.PostScore(name, dungeonData.Id, score); } private void LeaveDungeon() diff --git a/PuzzleGameProject/Assets/Scripts/Scores.meta b/PuzzleGameProject/Assets/Scripts/Scores.meta new file mode 100644 index 0000000..d43aa07 --- /dev/null +++ b/PuzzleGameProject/Assets/Scripts/Scores.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 294874e36d5de2f49b7a3532869a918e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PuzzleGameProject/Assets/Scripts/Scores/ScoreManager.cs b/PuzzleGameProject/Assets/Scripts/Scores/ScoreManager.cs new file mode 100644 index 0000000..e14a7a5 --- /dev/null +++ b/PuzzleGameProject/Assets/Scripts/Scores/ScoreManager.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections; +using DungeonSelection; +using UnityEngine; +using UnityEngine.Networking; +using UnityEngine.Serialization; + +namespace Scores +{ + [Serializable] + public class ScoreEntry + { + public int level_id; + public string player; + public int score; + public string timestamp; + } + + public class ScoreManager : MonoBehaviour + { + public event Action ScoresRecieved; + + private string _getScoresUrl = "https://games.maxdodd.net/get_scores.php"; + private string _postScoreUrl = "https://games.maxdodd.net/set_score.php"; + + private void OnEnable() + { + UIEvents.GetScores += GetScores; + } + + private void OnDisable() + { + UIEvents.GetScores -= GetScores; + } + + public void GetScores() + { + StartCoroutine(GetScoresFromServer()); + } + + public void PostScore(string planterName, int levelId, int score) + { + StartCoroutine(PostScoreToServer(planterName, levelId, score)); + } + + IEnumerator GetScoresFromServer() + { + using (UnityWebRequest request = UnityWebRequest.Get(_getScoresUrl)) + { + yield return request.SendWebRequest(); + + if (request.result == UnityWebRequest.Result.Success) + { + string jsonResponse = request.downloadHandler.text; + + try + { + // Parse the JSON response + ScoreEntry[] scores = JsonHelper.FromJson(jsonResponse); + + // Print out the scores + foreach (ScoreEntry score in scores) + { + ScoresRecieved?.Invoke(scores); + } + } + catch (Exception e) + { + Debug.LogError("Failed to parse scores: " + e.Message); + } + } + else + { + Debug.LogError("Failed to fetch scores: " + request.error); + } + } + } + + IEnumerator PostScoreToServer(string playerName, int levelId, int score) + { + Debug.Log("Post coroutine started"); + string url = _postScoreUrl; + WWWForm form = new WWWForm(); + form.AddField("player", playerName); + form.AddField("level_id", levelId); + form.AddField("score", score); + + using (UnityWebRequest request = UnityWebRequest.Post(url, form)) + { + Debug.Log("Sending Request"); + yield return request.SendWebRequest(); + Debug.Log("Request sent"); + + if (request.result == UnityWebRequest.Result.Success) + { + Debug.Log("Score submitted: " + request.downloadHandler.text); + } + else + { + Debug.LogError("Failed to submit score: " + request.error); + } + } + } + } + + // Helper class to handle JSON arrays + public static class JsonHelper + { + public static T[] FromJson(string json) + { + string wrappedJson = "{\"items\":" + json + "}"; + Wrapper wrapper = JsonUtility.FromJson>(wrappedJson); + return wrapper.items; + } + + [Serializable] + private class Wrapper + { + public T[] items; + } + } +} \ No newline at end of file diff --git a/PuzzleGameProject/Assets/Scripts/Scores/ScoreManager.cs.meta b/PuzzleGameProject/Assets/Scripts/Scores/ScoreManager.cs.meta new file mode 100644 index 0000000..b30c949 --- /dev/null +++ b/PuzzleGameProject/Assets/Scripts/Scores/ScoreManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: c4a5bac4f66aaf84991ec68d8f2a4705 \ No newline at end of file diff --git a/PuzzleGameProject/Assets/Scripts/UI/DungeonSelectMenuController.cs b/PuzzleGameProject/Assets/Scripts/UI/DungeonSelectMenuController.cs index 6addcec..0fa15f0 100644 --- a/PuzzleGameProject/Assets/Scripts/UI/DungeonSelectMenuController.cs +++ b/PuzzleGameProject/Assets/Scripts/UI/DungeonSelectMenuController.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using DungeonSelection; using Unity.VisualScripting; using UnityEngine; @@ -7,21 +8,25 @@ using UnityEngine.UIElements; public class DungeonSelectMenuController : MonoBehaviour { + private const int NUM_HIGH_SCORES = 10; + private Button _next; private Button _previous; private Button _start; private Image _thumbnailImage; private Label _dungeonName; private VisualElement _dungeonThumbnail; + private ListView _highScores; - private DungeonData _currentlyShowingDungeon; + private DungeonDisplayData _currentlyShowingDungeon; + private List _highScoreData = new List(); private void OnEnable() { VisualElement root = GetComponent().rootVisualElement; Button rules = root.Q