Exemple #1
0
    void Update()
    {
        var rate = LightManager.GetBatteryRate();

        Bar.fillAmount = rate;

        if (rate < 0.33f && !warned)
        {
            warned = true;

            transform.Find("LowBatteryAudio").GetComponent <AudioSource>().Play();
            GetComponent <Animator>().SetTrigger("LowBattery");
        }

        if (rate <= 0f)
        {
            Background.color = emptyColor;
            if (!emptied)
            {
                GetComponent <AudioSource>().Play();
            }
            emptied = true;
        }
        else
        {
            Background.color = backgroundColor;
        }
    }