DNF-timer + next car button when finished
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user