//数值修改逻辑 /// <summary> /// 伤害计算逻辑 /// </summary> /// <param name="dmg">伤害量(默认正号)</param> /// <param name="kind">伤害类型(不同防御力)</param> /// <param name="canReduce">能否被减伤</param> public void getDamage(int dmg, SkillKind kind, bool canReduce = true) { if (_unit.IsDead) { return; } if (SDGameManager.Instance.DEBUG_GODLIKE && _characterType == SDConstants.CharacterType.Hero) { dmg = 0; } if (canReduce) { float DmgR = AllRandomSetClass.SimplePercentToDecimal (Mathf.Abs(100 - _unit.ThisBasicRoleProperty().DmgReduction)); dmg = (int)(dmg * DmgR); } //配置额外伤害加成 dmg = _unit.IsEnemy ? _unit.BM.heroToEnemyDmg(dmg) : _unit.BM.enemyToHeroDmg(dmg); //Debug.Log(name + "是否被击中 闪避" + isEvoHappen + " " + "失误" + isFault); if (CurrentShieldHp > 0) { if (isEvoHappen || isFault) { dmg = 0; } //打破护盾 if (dmg >= CurrentShieldHp) { CurrentShieldHp = 0; checkShieldFull(); checkHpFull(); } else { CurrentShieldHp -= dmg; checkShieldFull(); } } else { int def = 0; if (kind == SkillKind.Physical) { def = _unit.ThisBasicRoleProperty()._role.ad; } else if (kind == SkillKind.Elemental) { def = _unit.ThisBasicRoleProperty()._role.md; } else if (kind == SkillKind.Arcane) { def = _unit.ThisBasicRoleProperty()._role.ad / 2 + _unit.ThisBasicRoleProperty()._role.md / 2; } dmg -= def; dmg = Mathf.Max(dmg, SDConstants.MinDamageCount); //添加Buff类建筑的影响 dmg = BattleGroupStateController.setNormalDmgByPlayerData(dmg, kind, _unit); if (isEvoHappen || isFault) { dmg = 0; } showDamageAnimation(dmg); //检测是否死亡 if (dmg >= CurrentHp) { _unit.IsDead = true; CurrentHp = 0; _unit.playDieAnimation(); } else { CurrentHp -= dmg; if (receiveExtraDamage) { getExtraDamage(currentExtraDamage); } else { _unit.playHurtAnimation(); } } checkHpFull(); } // _unit.CheckStatesWithTag_beAtked(); }