//Allows the Player to be dealt damage and does different things depending on what type of damage is being inflicted public void TakeDamage(int incomingDamage, DamageType dmgType) { if (dead || invulnerable) { return; } else { int finalDamage = ModifyDamage(incomingDamage, dmgType); if (finalDamage <= 0) { return; } switch (dmgType) { case DamageType.Fire: StopCoroutine("Burn"); StartCoroutine(Burn(5f, finalDamage / 2)); break; case DamageType.Frost: StopCoroutine(movement.Freeze()); StartCoroutine(movement.Freeze()); break; case DamageType.AutoStagger: StartCoroutine("Stagger"); break; case DamageType.Falling: if (fallInvulnerability) return; break; } health -= finalDamage; healthBar.value = health; poise -= incomingDamage; if (dmgType != DamageType.Falling && incomingDamage < health && poise < incomingDamage) { StartCoroutine("Stagger"); } } if (health <= 0) { Death(); } else { StartCoroutine("Invulnerability"); } } int ModifyDamage(int damage, DamageType dmgType) //Modifies damage depending on armor, resistance etc { if (dmgType == DamageType.Physical) { damage -= armor; } else foreach (DamageType resistance in resistances) { if (dmgType == resistance) { damage /= 2; break; } } return damage; }