private void PerformMeleeAttack() { float atkDefRatio = (float)user.stats.Att / (float)target.stats.Att; float power = basicAttackPowers[user.stats.BasicAttackLevel]; float agiRatio = Mathf.Sqrt((float)user.stats.Agi / (float)target.stats.Agi); AttackResult hit = AttackResultUtils.TryToHit(agiRatio); float damage = atkDefRatio * hit.DamageMultiplier() * power; target.currentHP -= (int)damage; user.currentMP -= (int)basicAttackCosts[user.stats.BasicAttackLevel]; HitsplatInfo info = new HitsplatInfo { damage = (int)damage, type = DamageType.SLASH, result = hit }; target.CreateHitsplat(info); }
private void PerformRangedAttack() { //Calculate the damage this projectile will cause. float atkDefRatio = (float)user.stats.Att / (float)target.stats.Att; float power = basicAttackPowers[range][user.stats.BasicAttackLevel]; float agiRatio = Mathf.Sqrt((float)user.stats.Agi / (float)target.stats.Agi); AttackResult hit = AttackResultUtils.TryToHit(agiRatio); float damage = atkDefRatio * hit.DamageMultiplier() * power; HitsplatInfo info = new HitsplatInfo { damage = (int)damage, type = DamageType.STAB, result = hit }; //Send the projectile on its way. It handles its own animation, etc, after that. RangedProjectile projectile = GameObject.Instantiate <RangedProjectile>(user.basicRangedProjectile); projectile.Init(10, user.transform.position, target, info, (int)damage); user.currentMP -= (int)basicAttackCosts[user.stats.BasicAttackLevel]; }