Driving UI
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEditor.SearchService;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -11,19 +12,28 @@ public class GameManager : MonoBehaviour
|
||||
public GameObject[] checkpoints;
|
||||
public GameObject[] players;
|
||||
[HideInInspector] public List<string> playersFinished;
|
||||
[HideInInspector] public List<string> playerTimes;
|
||||
|
||||
[HideInInspector] public float[] playerTimes;
|
||||
[HideInInspector] public string[] playerTimesStr;
|
||||
int[] playerLaps;
|
||||
public TextMeshProUGUI lapCounter;
|
||||
public TextMeshProUGUI timeCounter;
|
||||
void Start()
|
||||
{
|
||||
// reset laps
|
||||
playerLaps = new int[players.Count()];
|
||||
playerTimes = new float[players.Count()];
|
||||
|
||||
for (int i = 0; i < playerLaps.Count(); i++)
|
||||
{
|
||||
playerLaps[i] = 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < playerTimes.Count(); i++)
|
||||
{
|
||||
playerTimes[i] = 0;
|
||||
playerTimesStr[i] = "DNF";
|
||||
}
|
||||
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
@@ -46,7 +56,7 @@ public class GameManager : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
playerTimes[i] += Time.deltaTime;
|
||||
|
||||
bool isAI = true;
|
||||
if (player.GetComponent<PlayerController>().enabled)
|
||||
@@ -70,7 +80,10 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
player.GetComponent<PlayerController>().checkpointsCollected = 0;
|
||||
playerLaps[i] += 1;
|
||||
lapCounter.text = "Lap count: " + playerLaps[i];
|
||||
}
|
||||
|
||||
timeCounter.text = playerTimes[i].ToString();
|
||||
}
|
||||
|
||||
if (playerLaps[i] > lapAmount)
|
||||
@@ -84,8 +97,7 @@ public class GameManager : MonoBehaviour
|
||||
playersFinished.Add(player.name + " (player)");
|
||||
player.GetComponent<PlayerController>().enabled = false;
|
||||
|
||||
float time = Random.Range(15f, 40f);
|
||||
playerTimes.Add(time.ToString());
|
||||
playerTimesStr[i] = playerTimes[i].ToString();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user