Ejemplo n.º 1
0
    public void TakeDamage(DamageInfo damageInfo)
    {
        if (isDead)
        {
            return;
        }
        animator.SetTrigger(hitTriggerHash);
        int reduceDamage = enemyData.defence;

        if (damageInfo.isCriHit)
        {
            reduceDamage = 0;
        }
        int newDamage = Mathf.Clamp(damageInfo.damage - reduceDamage, 1, int.MaxValue);

        currentHealth -= newDamage;
        healthSlider.SetHealth(currentHealth);
        if (currentHealth <= 0)
        {
            currentHealth = 0;
            isDead        = true;
            animator.SetTrigger(dieTriggerHash);
            audioController.PlaySFX(dieClip);
        }
    }
Ejemplo n.º 2
0
 public void SetHealth(int health)
 {
     this.health = health;
     sliderHealth.SetHealth((float)health / Constants.MAX_HEALTH);
 }
 void LoseHealth(int healthLost) //Script to lose HP.
 {
     currentHealth -= healthLost;
     stageHealth.SetHealth(currentHealth); //We need to reduce our current health, and then set the slider value.
 }