This commit is contained in:
2024-04-26 13:48:57 +02:00
parent 57d61eb26b
commit 2374118538
2 changed files with 25 additions and 8 deletions

View File

@@ -33,7 +33,7 @@ public class GameManager : MonoBehaviour
for (int i = 0; i < players.Count(); i++)
{
playerTimes[i] = 0.00000001f;
playerTimesStr[i] = "DNF";
playerTimesStr[i] = "0";
}
DontDestroyOnLoad(gameObject);
@@ -42,8 +42,6 @@ public class GameManager : MonoBehaviour
// Update is called once per frame
void Update()
{
print("playersfinished: " + playersFinished.Count());
for (int i = 0; i < players.Count(); i++)
{
GameObject player = players[i];
@@ -121,6 +119,29 @@ public class GameManager : MonoBehaviour
// race finished
if (playersFinished.Count() == players.Count())
{
// sort array
float[] fTimes = new float[players.Count()];
for (int i = 0; i < players.Count(); i++)
{
fTimes[i] = float.Parse(playerTimesStr[i]);
}
Array.Sort(fTimes);
for (int i = 0; i < players.Count(); i++)
{
playerTimesStr[i] = fTimes[i].ToString();
try
{
playerTimesStr[i] = playerTimesStr[i].Substring(0, 7);
}
catch
{
}
}
SceneManager.LoadScene("WinScreen");
}