DNF-timer + next car button when finished

This commit is contained in:
magn9775
2024-04-26 18:21:02 +02:00
parent 69c51ec879
commit ef5c8e25a6
12 changed files with 736 additions and 239 deletions

View File

@@ -17,58 +17,55 @@ public class GameController :MonoBehaviour
public static bool RaceIsStarted { get { return true; } }
public static bool RaceIsEnded { get { return false; } }
//PlayerController m_PlayerCar;
//List<PlayerController> Cars = new List<PlayerController>();
public TextMeshPro speedometer;
public List<GameObject> cars;
int CurrentCarIndex = 0;
protected virtual void Awake ()
private List<string> finished;
void Start()
{
Instance = this;
finished=gameObject.GetComponent<GameManager>().playersFinished;
// foreach (var car in cars)
// {
// var userControl = car.GetComponent<PlayerController>();
// var audioListener = car.GetComponent<AudioListener>();
// if (userControl == null)
// {
// userControl = car.gameObject.AddComponent<PlayerController> ();
// }
// if (audioListener == null)
// {
// audioListener = car.gameObject.AddComponent<AudioListener> ();
// }
// userControl.enabled = false;
// audioListener.enabled = false;
// }
// cars[CurrentCarIndex].GetComponent<PlayerController>().enabled = true;
// cars[CurrentCarIndex].GetComponent<AudioListener>().enabled = true;
if (speedometer == null)
{
speedometer = new TextMeshPro();
}
if (carRB == null)
{
carRB = GetComponent<Rigidbody>();
}
}
void Update ()
public void Update ()
{
if (Input.GetKeyDown (NextCarKey))
{
NextCar ();
}
carVel = (math.abs(carRB.velocity.x) + math.abs(carRB.velocity.y) + math.abs(carRB.velocity.z))*5;
//print(carVel);
speedometer.SetText(carVel.ToString());
}
private void NextCar ()
public void NextCar()
{
// cars[CurrentCarIndex].GetComponent<PlayerController> ().enabled = false;
// cars[CurrentCarIndex].GetComponent<AudioListener> ().enabled = false;
for (int i = 0; i < cars.Count; i++)
{
if (finished.Contains(cars[i].name))
{
cars.Remove(cars[i]);
}
}
CurrentCarIndex = LoopClamp (CurrentCarIndex + 1, 0, cars.Count);
// cars[CurrentCarIndex].GetComponent<PlayerController>().enabled = true;
// cars[CurrentCarIndex].GetComponent<AudioListener>().enabled = true;
PlayerCar = cars[CurrentCarIndex];
@@ -90,4 +87,6 @@ public class GameController :MonoBehaviour
}
return value;
}
}