using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class HUDManager : MonoBehaviour { public Text[] tachometers; public Text[] maxSpeeds; public HUDProgress[] progressions; public Text[] distances; public float[] maxSpeedsValues = new float[2]; GameManager gm; void Awake() { } // Use this for initialization void Start () { gm = GameManager.Instance; gm.RegisterHUD(this); gm.Hello(); } // Update is called once per frame void Update () { UpdateSpeeds(0); UpdateProgress(0); UpdateDistance(0); } void UpdateDistance(int bikeID) { distances[bikeID].text = gm.GetBikeManager(bikeID).GetDistance().ToString("#0") + "m"; } void UpdateProgress(int bikeID) { progressions[bikeID].SetProgress(gm.GetBikeManager(bikeID).GetProgress()); } void UpdateSpeeds(int bikeID) { float s = gm.GetBikeManager(bikeID).Speed; if (s > maxSpeedsValues[bikeID]) maxSpeedsValues[bikeID] = s; tachometers[bikeID].text = (s * 3.6f).ToString("#0.0") + "km/h"; maxSpeeds[bikeID].text = "Max : " + (maxSpeedsValues[bikeID] * 3.6f).ToString("#0.0"); } }