Пример #1
0
    // Update is called once per frame

    void FixedUpdate()
    {
        // If the next update is reached
        if (Time.time >= nextUpdate)
        {
            // Change the next update (current second+1)
            nextUpdate = (Mathf.FloorToInt(Time.time) + 1);
            // Call your function
            UpdateEverySecond();
        }

        // Update is called once per second
        void UpdateEverySecond()
        {
            speed      = Mathf.Round(_carController.GetCurrentSpeedInKmH());
            Speed.text = speed + "";
            //speedLimit = Mathf.RoundToInt(_aimedSpeed.GetRuleSpeed());
            speedLimit = Mathf.RoundToInt(_aimedSpeed.GetRuleSpeed());
            float quotientSpeed = speed / speedLimit;

            SpeedGauge.fillAmount = 0.75f * (Mathf.Round(quotientSpeed * 36) / 36);


            if (speed >= (speedLimit + 5))
            {
                SpeedGauge.color = Color.red;
                Speed.color      = Color.red;
                //MaxSpeed.color = Color.red;
            }
            else
            {
                SpeedGauge.color = Color.green;
                Speed.color      = Color.green;
                MaxSpeed.color   = Color.white;
            }

            //Datum
            var today = System.DateTime.Now;

            if (ShowRealTime)
            {
                Date.text = today.ToString("HH:mm");
            }
            else
            {
                Date.text = ShowFakeTime;
            }
            //MaxSpeed
            MaxSpeed.text = speedLimit + "";
            // Weather.text = "Westbrueck \n 22°C";
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        speed           = Mathf.Round(_carController.GetCurrentSpeedInKmH());
        SpeedMeter.text = speed + "";
        speedLimit      = Mathf.RoundToInt(_aimedSpeed.GetRuleSpeed());
        float quotientSpeed = speed / speedLimit;

        SpeedGauge.fillAmount = 0.5f * (Mathf.Round(quotientSpeed * 36) / 36);
        RPM = DynamicCarSound.RotationPerMoment(speed);
        RPMGauge.fillAmount = 0.5f * Mathf.Round(RPM * 10) / 300;
        RPMMeter.text       = RPM * 100 + "";
        //Steering wheel update
    }