Пример #1
0
    public void TakeDamage(float damage)
    {
        healthSlider.SubtractHealth(damage);

        StartCoroutine(setUnderAttack());

        healthText.text = ((int)healthSlider.Health).ToString();

        var position = transform.position;

        position.Set(position.x, position.y + HEIGHT_OFFSET, position.z);
        var text_holder = Instantiate(dmgTakenText, position, Quaternion.Euler(Camera.main.transform.eulerAngles));

        text_holder.transform.GetChild(0).GetComponent <TextMeshPro>().SetText("- " + damage);

        if (healthSlider.Health <= 0)
        {
            if (Faction == FactionEnum.Player)
            {
                menuScript.GameOver();
            }
            else
            {
                menuScript.GameWin();
            }
        }
    }