public void DealDamageToTarget(UnitStats target) { if (ability.abilityType == AbilityType.Physical) { int dmg = Mathf.RoundToInt(ability.damage * (((flow.currentUnit.modAttack * flow.currentUnit.modAttack) / 6) + ability.damage) / 4); int defNum = Mathf.RoundToInt((((target.modDefense - 280.4f) * (target.modDefense - 280.4f) / 110) + 16)); int dmg2 = (dmg * defNum) / 730; int finalDmg = dmg2 * (730 - (target.modDefense * 51 - (target.modDefense * target.modDefense) / 11) / 10) / 730; int modFinalDmg = finalDmg; if (target.charMode == Mode.Defense) { modFinalDmg = Mathf.RoundToInt(modFinalDmg / 2); } target.ReceiveDamage(modFinalDmg); ui.ShowDamageText(target, modFinalDmg); } else { int dmg = Mathf.RoundToInt(ability.damage * (((flow.currentUnit.modMagAttack * flow.currentUnit.modMagAttack) / 6) + ability.damage) / 4); int defNum = Mathf.RoundToInt((((target.modMagDefense - 280.4f) * (target.modMagDefense - 280.4f) / 110) + 16)); int dmg2 = (dmg * defNum) / 730; int finalDmg = dmg2 * (730 - (target.modMagDefense * 51 - (target.modMagDefense * target.modMagDefense) / 11) / 10) / 730; int modFinalDmg = finalDmg; if (target.charMode == Mode.Defense) { modFinalDmg = Mathf.RoundToInt(modFinalDmg / 2); } target.ReceiveDamage(Mathf.RoundToInt(modFinalDmg)); ui.ShowDamageText(target, modFinalDmg); } if (target.IsDead()) { target.battleAnimator.GetComponent <Animator>().Play("Die"); flow.units.Remove(target); } else { target.battleAnimator.GetComponent <Animator>().Play("Hit" + target.facing.ToString()); } }