Exemplo n.º 1
0
    public void TakeDamage(int damage)
    {
        damage -= armor.GetValue();
        damage  = Mathf.Clamp(damage, 0, int.MaxValue);

        currentHealth -= damage;
//		Debug.Log(transform.name + "takes " + damage + "damage.");

        if (currentHealth <= 0)
        {
            Die();
        }
    }
Exemplo n.º 2
0
    public void TakeDamage(int damage)
    {
        //prevents some damage depending on armor stats
        damage -= armor.GetValue();
        damage  = Mathf.Clamp(damage, 0, int.MaxValue);


        currentHealth -= damage;
        print(currentHealth + " " + maxHealth);

        hpRemain = (float)currentHealth / maxHealth;

        print(hpRemain);
        gameObject.GetComponent <HealthBarControl>().setHealthBar(hpRemain);
        Debug.Log(transform.name + " takes " + damage + " damage ");

        if (currentHealth <= 0)
        {
            Die();
        }
    }
    // Damage the character
    public void TakeDamage(int damage)
    {
        // Subtract the armor value
        damage -= armor.GetValue();
        damage  = Mathf.Clamp(damage, 0, int.MaxValue);

        // Damage the character
        currentHealth -= damage;
        Debug.Log(transform.name + " takes " + damage + " damage.");


        if (OnHealthChanged != null)
        {
            OnHealthChanged(maxHealth, currentHealth);
            //healthbar.SetMaxHealth(currentHealth);
        }

        // If health reaches zero
        if (currentHealth <= 0)
        {
            Die();
        }
    }