time fix
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user