Example #1
0
    void OnHPChanged(int HP)
    {
        if (isLocalPlayer)
        {
            if (uiStatus != null)
            {
                uiStatus.UpdateHP(HP);
            }

            if (HP <= maxHP * 0.2f)
            {
                survivorAudio.PlayHeartSound();
            }
            else if (HP > maxHP * 0.2f)
            {
                survivorAudio.StopHeartSound();
            }

            if (((float)HP / maxHP) <= ((float)hunger / maxHunger))
            {
                uiSurvivor.SetVignette(255f * (1f - Mathf.Clamp((((float)HP / maxHP - 0.2f) * 3.333f), 0f, 1f)));
            }
            else
            {
                uiSurvivor.SetVignette(255f * (1f - Mathf.Clamp((((float)hunger / maxHunger - 0.2f) * 3.333f), 0f, 1f)));
            }

            this.HP = HP;

            if (HP <= 0)
            {
                dead();
            }
        }
    }