public void Take_damage(int damage, Ability attack_stats, float score) { damage = CheckElementalEffects(attack_stats, damage); switch (attack_stats._typ) { case ability_typ.physical: damage -= ApplyScore(defence, score); break; case ability_typ.magical: damage -= ApplyScore(resistance, score); break; default: break; } if (Effects.Check_for_effect(attack_stats.effect_array, effects.absorb) != null) { var effect_stats = Effects.Check_for_effect(attack_stats.effect_array, effects.absorb); attack_stats.GetUser().Heal(Effects.Absorb(damage, effect_stats.value1)); } if (damage > 0) { GetComponent <CharacterAnimation>().Take_Damage(); } showDamageNumber(damage); hp -= Mathf.Max(0, damage); if (hp <= 0) { if (CheckForPassiv(passiveSkill.Phenix) && !phenix_used) { phenix_used = true; mp = Mathf.Max(0, mp - 10); hp = 0; Heal(hp_max / 2, false); } else { Debug.Log("plea ded"); FindObjectOfType <SceneTransitioner>().LoadGameFile(); shaker.ShakeCam(shake.extrem); } } else if (damage > 0) { shaker.ShakeCam(shake.medium); } UI.UpdateSlider(); }
public void Take_damage(int damage, Ability attack_stats) { switch (attack_stats._typ) { case ability_typ.physical: damage -= defence; break; case ability_typ.magical: damage -= resistance; break; default: break; } damage = CheckForElementEffects(damage, attack_stats); switch (resistens) { case EnemyResistens.Resistend: if (attack_stats._typ == ability_typ.magical) { damage = damage / 2; } break; case EnemyResistens.Defesive: if (attack_stats._typ == ability_typ.physical) { damage = damage / 2; } break; default: break; } if (Effects.Check_for_effect(attack_stats.effect_array, effects.absorb) != null) { var effect_stats = Effects.Check_for_effect(attack_stats.effect_array, effects.absorb); FindObjectOfType <PlayerStats>().Heal(Effects.Absorb(Mathf.Min(hp, damage), effect_stats.value1), true); } if (Effects.Check_for_effect(attack_stats.effect_array, effects.oneShotBoost) != null) { if (Effects.maxHealthBoost(hp_max, hp)) { var effect_stats = Effects.Check_for_effect(attack_stats.effect_array, effects.oneShotBoost); damage = (int)(damage * effect_stats.value1); } } if (damage > 0) { GetComponent <CharacterAnimation>().Take_Damage(); } hp -= Mathf.Max(0, damage); showDamageNumber(damage); UI.slider.maxValue = hp_max; UI.slider.value = hp; UI.hp_text.text = hp.ToString() + "/" + hp_max.ToString(); if (hp <= 0) { showXPNumber(souls_drop); Defeated(attack_stats); shaker.ShakeCam(shake.big); } else if (damage > 0) { shaker.ShakeCam(shake.small); } }