Added basic score tracking

This commit is contained in:
Pasha Bibko
2026-01-22 10:52:56 +00:00
parent cdb9255190
commit 59f4f987a7
5 changed files with 371 additions and 16 deletions

View File

@@ -0,0 +1,40 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace InterfaceOff.WorldScene
{
[System.Serializable] public struct PlayerScore
{
private string PlayerName;
private float Score;
}
public class ScoreTracker : MonoBehaviour
{
[field: SerializeField] private bool GameAngliaVersion { get; set; }
[field: SerializeField] private Text ScoreText { get; set; }
[field: SerializeField] private Text FinalScoreText { get; set; }
[field: SerializeField] private WindowSpawner Spawner { get; set; }
private static List<PlayerScore> PlayerScores { get; } = new();
private bool StoredScore = false;
private float Score = 0f;
private void Update()
{
if (Spawner.AutoSpawn)
{
ScoreText.text = $"Score: {Time.timeSinceLevelLoad:F1}";
Score = Time.timeSinceLevelLoad;
}
else
{
FinalScoreText.text = $"Your final score is: {Score:F1}";
ScoreText.text = null;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0d56c8d3df304813a6e3861d997167d8
timeCreated: 1769076867