Exemplo n.º 1
0
    void Update()
    {
        if (gameMgr.isStart)
        {
            currentHp       -= Time.deltaTime * 1f / sectorData.hpTime;
            hpBar.fillAmount = (float)currentHp / (float)maxHp;
            hp.text          = ((int)currentHp).ToString() + "/" + ((int)maxHp).ToString();
            if (currentHp <= 20 && !isEmergencyBgm)
            {
                isEmergencyBgm = true;
                bgmMgr.OnHpEnergency();
            }
            else if (currentHp >= 20 && isEmergencyBgm)
            {
                isEmergencyBgm = false;
                bgmMgr.OnHpHealed();
            }
            if (currentHp / maxHp >= 0.5f)
            {
                hpBar.sprite = normalHpSprite;
            }
            else
            {
                hpBar.sprite = dangerHpSprite;
            }

            if (currentHp < 0)
            {
                GameOver();
            }
        }
    }