override public void LoseHealth(GameObject attacker, string attackerType, float damage, bool typeMagical) { if (!enraged && health <= maxHealth / 3) { enraged = true; moveTime = moveTime / 3; attackSpeed = attackSpeed / 3; LogText.GetComponent <Text>().text += '\n' + gameObject.name + " has become enraged"; } base.LoseHealth(attacker, attackerType, damage, typeMagical); }
override public void LoseHealth(GameObject attacker, string attackerType, float damage, bool typeMagical) { float dmgTaken; if (typeMagical) { dmgTaken = damage * (1 - magicalArmorPercent); health = health - dmgTaken; } else { dmgTaken = damage * (1 - physicalArmorPercent); health = health - dmgTaken; } healthBar.fillAmount = health / maxHealth; //Debug.Log(attacker.name + " is attacking " + gameObject.name + " for " + dmgTaken + " damage!"); if (health <= 0) { if (died) { //transform.gameObject.tag = "Dead"; //Play death animation GameObject effectAudio = GameObject.Find("EffectsSource"); AudioSource audio = effectAudio.GetComponent <AudioSource>(); audio.clip = deathSound; audio.enabled = true; audio.Play(); LogText.GetComponent <Text>().text += '\n' + gameObject.name + " was killed by " + attacker.name; transform.gameObject.SetActive(false); } else { health = maxHealth / 4; magicalArmorPercent = 0; physicalArmorPercent = 0; attack = attack * 2; healthBar.fillAmount = health / maxHealth; died = true; LogText.GetComponent <Text>().text += '\n' + gameObject.name + " revived"; } } }