fixed build freezing issue, added decorations to door card readers

This commit is contained in:
2025-08-29 15:53:25 +03:00
parent 317d74dfef
commit 9f65f3d476
16 changed files with 794 additions and 16 deletions

View File

@@ -33,26 +33,39 @@ public class ScoreBoard : MonoBehaviour
public void SaveScore(string playerName, float score)
{
LoadScores();
LoadScores(); // Make sure we<77>re working with the latest data
_scoreData.entries.Add(new ScoreEntry { name = playerName, score = score });
_scoreData.entries = _scoreData.entries.OrderByDescending(e => e.score).Take(15).ToList(); // Keep top 15
// Keep only the top 15 scores
_scoreData.entries = _scoreData.entries
.OrderByDescending(e => e.score)
.Take(15)
.ToList();
// Convert to JSON
string json = JsonUtility.ToJson(_scoreData, true);
File.WriteAllText(filePath, json);
// Save JSON next to the executable
File.WriteAllText("highscores.json", json);
DisplayTopScores();
}
public void LoadScores()
{
if (File.Exists(filePath))
if (File.Exists("highscores.json"))
{
string json = File.ReadAllText(filePath);
string json = File.ReadAllText("highscores.json");
_scoreData = JsonUtility.FromJson<ScoreData>(json);
Debug.Log(Application.persistentDataPath);
}
else
{
_scoreData = new ScoreData(); // Start fresh if no file exists
}
}
private void DisplayTopScores()
{
if (_scoreData.entries.Count == 0)