public DamageInfo TakeDamage(AbilityStep_Damage stepInfo, HealthEntityCombatObject attacker) { var result = DamageCalculator.CaclulateFlatDamage(stepInfo, attacker, this); /* * if (IsDead) * { * return default(DamageInfo); * } * * if (IsImmuneToDamage()) * { * Animator.SetTrigger("Block"); * DamageNumberCanvas canv = GameObject.Instantiate(FindObjectOfType<CombatManager>().damageNumberCanvasPrefab).GetComponent<DamageNumberCanvas>(); * canv.Display("Immune", Color.magenta); * canv.transform.position = transform.position; * return default(DamageInfo); * } */ DamageInfo damageInfo = new DamageInfo(); /* * * int amount = stepInfo.amount; * amount = Mathf.Max(0, amount); * if (attacker != null) * { * amount = (int)(amount * attacker.Stats.rawDamageMultiplier.Value); * } * * float random = Random.Range(0f, 1f); * float attackerCritChance = attacker.Stats.criticalChance.Value; * * foreach (var statusEffect in StatusEffects) * { * foreach (var behaviour in statusEffect.behaviour) * { * if (behaviour is WeakenBehaviour weaken) * { * attackerCritChance *= weaken.modifyCritChanceAgainst; * } * } * } * * bool crit = false; * if (attacker != null && random < attackerCritChance && stepInfo.canCriticallyStrike) * { * crit = true; * amount *= 2; * } * * switch (stepInfo.damageTypePerc) * { * case AbilityStep_Damage.DamageTypePerc.PercentageMaxHP: * amount = (int)(MaxHealth * (amount / 100f)); * break; * case AbilityStep_Damage.DamageTypePerc.None: * amount = 0; * break; * } * * switch (stepInfo.damageType) * { * case AbilityStep_Damage.DamageType.Physical: * amount = (int)Mathf.Ceil(amount * (1 - Mathf.Clamp01(Stats.armor.Value - ((attacker != null) ? attacker.Stats.armorPenetration.Value : 0)))); * break; * case AbilityStep_Damage.DamageType.Magic: * amount = (int)Mathf.Ceil(amount * (1 - Mathf.Clamp01(Stats.magicResist.Value - ((attacker != null) ? attacker.Stats.magicPenetration.Value : 0)))); * break; * case AbilityStep_Damage.DamageType.None: * amount = 0; * break; * }*/ //int amountRemaining = amount; switch (result.name) { case DamageCalculator.ClashResult.Name.Failed: return(default); case DamageCalculator.ClashResult.Name.Immune: Animator.SetTrigger("Block"); DamageNumberCanvas canv = GameObject.Instantiate(FindObjectOfType <CombatManager>().damageNumberCanvasPrefab).GetComponent <DamageNumberCanvas>(); canv.Display("Immune", Color.magenta); canv.transform.position = transform.position; return(default); } ReduceBlock(ref result.damage); /* * amountRemaining -= Block; * ModifyBlock(-amount); * * amountRemaining = Mathf.Clamp(amountRemaining, 0, amountRemaining);*/ if (result.damage > 0) { damageInfo.damageDealt = result.damage; DamageNumberCanvas canv = GameObject.Instantiate(FindObjectOfType <CombatManager>().damageNumberCanvasPrefab).GetComponent <DamageNumberCanvas>(); if (result.criticalHit) { canv.Display("CRIT! " + damageInfo.damageDealt.ToString(), Color.red); } else { canv.Display(damageInfo.damageDealt.ToString(), Color.red); } canv.transform.position = transform.position; Entity.Health -= damageInfo.damageDealt; Entity.Health = Mathf.Clamp(Health, 0, MaxHealth); if (Entity.Health > 0) { Animator.SetTrigger("Hit"); } } else { Animator.SetTrigger("Block"); DamageNumberCanvas canv = GameObject.Instantiate(FindObjectOfType <CombatManager>().damageNumberCanvasPrefab).GetComponent <DamageNumberCanvas>(); canv.Display("Blocked", Color.grey); canv.transform.position = transform.position; } if (attacker != null) { if (OnAttackedBehaviour != null) { OnAttackedBehaviour(attacker); } } if (Health <= 0) { Die(); OnDeath(this); } RefreshUI(); return(damageInfo); }