public static ACT.ECombatResult Combat(Unit self, Unit target, out int finallyDamage) { int damage = self.GetAttr(EPA.Attack); int defence = target.GetAttr(EPA.Defense); finallyDamage = Mathf.Max(damage - defence, 0); ACT.ECombatResult result = ACT.ECombatResult.ECR_Normal; { int critical = self.GetAttr(EPA.Critical); int hit = self.GetAttr(EPA.Hit); int block = target.GetAttr(EPA.Block); int tough = target.GetAttr(EPA.Tough); int MAX_RATIO_VALUE = 10000; block = Mathf.Clamp(block - hit, 0, MAX_RATIO_VALUE / 2); critical = Mathf.Clamp(critical - tough, 0, MAX_RATIO_VALUE / 2); int rand = UnityEngine.Random.Range(0, MAX_RATIO_VALUE + 1); if (rand < block) { result = ACT.ECombatResult.ECR_Block; finallyDamage = 0; } else if (rand < block + critical) { result = ACT.ECombatResult.ECR_Critical; finallyDamage = finallyDamage * 150 / 100; } } return(result); }
public override void Hurt(Unit attacker, int damage, int dpDamage, ACT.ECombatResult result) { base.Hurt(attacker, damage, dpDamage, result); GetComponent <HudPopupComponent>().Popup(EHudPopupType.Damage, damage); Game.ControllerMgr.Get <UnitController>().SetHitedMonster(this); }
public virtual void Hurt(Unit attacker, int damage, int dpDamage, ACT.ECombatResult result) { if (Dead) { return; } AddHp(-damage); if (0 != dpDamage) { AddDp(-dpDamage); } }
public override ACT.ECombatResult Combat(ACT.IActUnit target, ACT.ISkillItem skillItem) { int tmpDamage = 0; int tmpDpDamage = 0; Unit tmpTarget = target as Unit; ACT.ECombatResult tmpResult = ACT.ECombatResult.ECR_Normal; if (tmpTarget.ActStatus.ActionState == ActData.EActionState.Defense) { tmpResult = ACT.ECombatResult.ECR_Block; } else { tmpResult = MathUtility.Combat(this, tmpTarget, out tmpDamage); } if (ACT.ECombatResult.ECR_Block != tmpResult) { if (null != skillItem) { int tmpDamageCoff = (skillItem as SkillItem).SkillAttrBase.DamageCoff; int tmpDamageBase = (skillItem as SkillItem).SkillAttrBase.DamageBase; // 技能的影响。 tmpDamage = (int)(tmpDamage * tmpDamageCoff * 0.01f + tmpDamageBase); int tmpDpDamageCoff = (skillItem as SkillItem).SkillAttrBase.DpDamageCoff; tmpDpDamage = (int)(tmpTarget.GetAttr(EPA.DpAttack) * tmpDpDamageCoff * 0.01f); } // damage should not be 0. tmpDamage = Mathf.Max(tmpDamage, 1); tmpTarget.Hurt(this, tmpDamage, tmpDpDamage, tmpResult); } else { target.Combat(this, target.ActStatus.SkillItem); Game.CameraActionMgr.StartAction(101); } return(tmpResult); }
public override void Hurt(Unit attacker, int damage, int dpDamage, ACT.ECombatResult result) { base.Hurt(attacker, damage, dpDamage, result); GetComponent <HudPopupComponent>().Popup(EHudPopupType.Damage, damage); }