| | |
| | | 189f / 255f); |
| | | |
| | | protected SkillEffect skillEffect; |
| | | protected HB427_tagSCUseSkill tagUseSkillAttack; |
| | | public HB427_tagSCUseSkill tagUseSkillAttack; |
| | | public SkillConfig skillConfig; |
| | | protected bool isFinished = false; |
| | | protected BattleField battleField = null; // 战场 |
| | | protected RectTransform targetNode = null; // 目标节点 |
| | | protected BattleObject caster = null; // 施法者 |
| | | public BattleObject caster = null; // 施法者 |
| | | protected List<GameNetPackBasic> packList; |
| | | protected List<SkillRecordAction> otherSkillActionList = new List<SkillRecordAction>(); |
| | | protected List<H0704_tagRolePackRefresh> dropPackList = new List<H0704_tagRolePackRefresh>(); |
| | | protected List<HB405_tagMCAddExp> expPackList = new List<HB405_tagMCAddExp>(); |
| | | protected bool moveFinished = false; |
| | | public int fromSkillId; |
| | | public SkillBase fromSkill; |
| | | public bool isPlay = false; |
| | | |
| | | private float MoveSpeed = 750f; |
| | |
| | | tagUseSkillAttack = vNetData; |
| | | battleField = _battleField; |
| | | packList = _packList; |
| | | |
| | | SafetyCheck(); |
| | | #if UNITY_EDITOR |
| | | if (Launch.Instance.isOpenSkillLogFile) |
| | | { |
| | | PinrtHB427Hp(); |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | public static Dictionary<string, string> changeListDict = new Dictionary<string, string>(); |
| | | #endif |
| | | private void PinrtHB427Hp() |
| | | { |
| | | #if UNITY_EDITOR |
| | | string skillDetail = "SkillCaster : " + tagUseSkillAttack.ObjID + " -> cast SkillID: " + skillConfig.SkillID + "\n"; |
| | | |
| | | skillDetail += "------------------ HurtList ------------------\n"; |
| | | for (int i = 0; i < tagUseSkillAttack.HurtCount; i++) |
| | | { |
| | | var Hurt = tagUseSkillAttack.HurtList[i]; |
| | | BattleObject battleObject = caster.battleField.battleObjMgr.GetBattleObject((int)Hurt.ObjID); |
| | | |
| | | string targetName = battleObject != null ? battleObject.teamHero.name : "Unknown"; |
| | | long hurtHp = GeneralDefine.GetFactValue(Hurt.HurtHP, Hurt.HurtHPEx); |
| | | long curHp = GeneralDefine.GetFactValue(Hurt.CurHP, Hurt.CurHPEx); |
| | | |
| | | skillDetail += $" [{i}] Target: {targetName} (ObjID:{Hurt.ObjID})\n"; |
| | | skillDetail += $" HurtHP: {hurtHp}\n"; |
| | | skillDetail += $" CurHP: {curHp}\n"; |
| | | skillDetail += $" SuckHP: {Hurt.SuckHP}\n"; |
| | | skillDetail += $" BounceHP: {Hurt.BounceHP}\n"; |
| | | skillDetail += $" AttackTypes: {Hurt.AttackTypes}\n"; |
| | | |
| | | if (Hurt.HurtListEx != null && Hurt.HurtListEx.Length > 0) |
| | | { |
| | | skillDetail += $" HurtListEx ({Hurt.HurtListEx.Length}):\n"; |
| | | for (int j = 0; j < Hurt.HurtListEx.Length; j++) |
| | | { |
| | | var hurtEx = Hurt.HurtListEx[j]; |
| | | long hurtExHp = GeneralDefine.GetFactValue(hurtEx.HurtHP, hurtEx.HurtHPEx); |
| | | long curExHp = GeneralDefine.GetFactValue(hurtEx.CurHP, hurtEx.CurHPEx); |
| | | |
| | | skillDetail += $" [{j}] ObjID:{hurtEx.ObjID} HurtHP:{hurtExHp} CurHP:{curExHp} SuckHP:{hurtEx.SuckHP} AttackTypes:{hurtEx.AttackTypes}\n"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | skillDetail += "------------------ HurtListEx ------------------\n"; |
| | | if (tagUseSkillAttack.HurtListEx != null) |
| | | { |
| | | for (int i = 0; i < tagUseSkillAttack.HurtListEx.Length; i++) |
| | | { |
| | | var HurtEx = tagUseSkillAttack.HurtListEx[i]; |
| | | BattleObject battleObject = caster.battleField.battleObjMgr.GetBattleObject((int)HurtEx.ObjID); |
| | | |
| | | string targetName = battleObject != null ? battleObject.teamHero.name : "Unknown"; |
| | | long hurtHp = GeneralDefine.GetFactValue(HurtEx.HurtHP, HurtEx.HurtHPEx); |
| | | long curHp = GeneralDefine.GetFactValue(HurtEx.CurHP, HurtEx.CurHPEx); |
| | | |
| | | skillDetail += $" [{i}] Target: {targetName} (ObjID:{HurtEx.ObjID})\n"; |
| | | skillDetail += $" HurtHP: {hurtHp}\n"; |
| | | skillDetail += $" CurHP: {curHp}\n"; |
| | | skillDetail += $" SuckHP: {HurtEx.SuckHP}\n"; |
| | | skillDetail += $" AttackTypes: {HurtEx.AttackTypes}\n"; |
| | | } |
| | | } |
| | | |
| | | skillDetail += "------------------ END ------------------\n"; |
| | | |
| | | if (changeListDict.ContainsKey(caster.battleField.guid)) |
| | | { |
| | | string origin = changeListDict[caster.battleField.guid]; |
| | | origin += skillDetail; |
| | | changeListDict[caster.battleField.guid] = origin; |
| | | |
| | | } |
| | | else |
| | | changeListDict.Add(caster.battleField.guid, skillDetail); |
| | | |
| | | Debug.LogError("skillDetail : " + skillDetail); |
| | | #endif |
| | | } |
| | | |
| | | private void SafetyCheck() |
| | | { |
| | | bool safety = caster != null |
| | | && skillConfig != null |
| | | && tagUseSkillAttack != null |
| | | && battleField != null |
| | | && caster.IsDead() == false; |
| | | |
| | | |
| | | if (!safety) |
| | | { |
| | | Debug.LogError("SkillBase SafetyCheck failed! Caster or SkillConfig or TagUseSkillAttack or BattleField is null, or Caster is dead."); |
| | | ForceFinished(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | // 技能运行主逻辑:处理技能效果和其他技能动作 |
| | |
| | | TeamHero teamHero = caster.teamHero; |
| | | EventBroadcast.Instance.Broadcast<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, guid, skillConfig, teamHero); |
| | | |
| | | if (skillConfig.SkinllSFX1 != 0) |
| | | { |
| | | battleField.soundManager.PlayEffectSound(skillConfig.SkinllSFX1, false); |
| | | } |
| | | |
| | | if (caster != null) |
| | | { |
| | | // 战斗类型 0-常规;1-连击;2-反击;3-追击;4-子技能;5-被动触发的 |
| | |
| | | hintConfig = DamageNumConfig.Get(BattleConst.BattleChaseAttack); |
| | | } |
| | | |
| | | if (hintConfig != null) |
| | | { |
| | | caster.heroInfoBar.ShowTips(((char)hintConfig.prefix).ToString(), true, false, 1.25f); |
| | | // Debug.Break(); |
| | | } |
| | | Hint(caster, hintConfig); |
| | | |
| | | |
| | | } |
| | | |
| | | // 高亮所有本次技能相关的目标 |
| | |
| | | Debug.LogError("强制结束技能 暂时不支持其他的方式释放 有需求please联系策划 技能id:" + skillConfig.SkillID + " cast position " + skillConfig.CastPosition); |
| | | ForceFinished(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | protected void Hint(BattleObject battleObject, DamageNumConfig hintConfig) |
| | | { |
| | | if (hintConfig != null) |
| | | { |
| | | battleObject.heroInfoBar.ShowTips(((char)hintConfig.prefix).ToString(), true, false, 1.25f); |
| | | } |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | int mainTargetPosNum = BattleUtility.GetMainTargetPositionNum(caster, tagUseSkillAttack.HurtList.ToList(), skillConfig); |
| | | int mainTargetPosNum = BattleUtility.GetMainTargetPositionNum(this, caster, tagUseSkillAttack.HurtList.ToList(), skillConfig); |
| | | BattleCamp battleCamp = skillConfig.TagFriendly != 0 ? caster.Camp : caster.GetEnemyCamp(); |
| | | RectTransform targetTrans = battleField.GetTeamNode(battleCamp, mainTargetPosNum); |
| | | |
| | |
| | | ShadowIllutionCreate(true); |
| | | MoveToTarget(target, new Vector2(skillConfig.CastDistance, 0), () => |
| | | { |
| | | if (skillConfig.CastDistance < 9999 && skillConfig.SkinllSFX2 != 0) |
| | | { |
| | | battleField.soundManager.PlayEffectSound(skillConfig.SkinllSFX2, false); |
| | | } |
| | | |
| | | TurnBack(() => |
| | | { |
| | | ShadowIllutionCreate(false); |
| | | |
| | | CastImpl(() => |
| | | { |
| | | TurnBack(() => |
| | |
| | | // 技能开始回调:处理死亡、子技能、技能效果初始化 |
| | | public void OnSkillStart() |
| | | { |
| | | if (isPlay) |
| | | { |
| | | Debug.LogError(" play twice OnSkillStart skillId :" + skillConfig.SkillID); |
| | | return; |
| | | } |
| | | |
| | | HandleDead(); |
| | | |
| | | skillEffect = SkillEffectFactory.CreateSkillEffect(caster, skillConfig, tagUseSkillAttack); |
| | | |
| | | skillEffect = SkillEffectFactory.CreateSkillEffect(this, caster, skillConfig, tagUseSkillAttack); |
| | | skillEffect.Play(OnHitTargets); |
| | | foreach (var subSkillPack in tagUseSkillAttack.subSkillList) |
| | | { |
| | | SkillRecordAction recordAction = CustomHB426CombinePack.CreateSkillAction(battleField.guid, new List<GameNetPackBasic>() { subSkillPack }); |
| | | recordAction.fromSkill = this; |
| | | otherSkillActionList.Add(recordAction); |
| | | battleField.recordPlayer.ImmediatelyPlay(recordAction); |
| | | } |
| | | tagUseSkillAttack.subSkillList.Clear(); |
| | | foreach (var subCombinePack in tagUseSkillAttack.subSkillCombinePackList) |
| | | { |
| | | SkillRecordAction recordAction = CustomHB426CombinePack.CreateSkillAction(battleField.guid, subCombinePack.packList); |
| | | recordAction.fromSkill = this; |
| | | otherSkillActionList.Add(recordAction); |
| | | battleField.recordPlayer.ImmediatelyPlay(recordAction); |
| | | } |
| | | tagUseSkillAttack.subSkillCombinePackList.Clear(); |
| | | |
| | | isPlay = true; |
| | | } |
| | | |
| | |
| | | if (skillConfig.FuncType != 2) |
| | | return; |
| | | |
| | | List<BattleObject> targetList = battleField.battleObjMgr.GetBattleObjList(tagUseSkillAttack); |
| | | List<BattleObject> highlightList = new List<BattleObject>(targetList) { caster }; |
| | | List<BattleObject> allList = battleField.battleObjMgr.allBattleObjDict.Values.ToList<BattleObject>(); |
| | | |
| | | // 修复:使用HashSet优化性能,避免重复设置 |
| | | var targetSet = new HashSet<BattleObject>(targetList); |
| | | // 收集所有目标(包含 HurtList、每个 Hurt 的 HurtListEx、以及顶层 HurtListEx) |
| | | var targetSet = new HashSet<BattleObject>(); |
| | | if (tagUseSkillAttack != null) |
| | | { |
| | | // 主目标列表 |
| | | if (tagUseSkillAttack.HurtList != null) |
| | | { |
| | | foreach (var hurt in tagUseSkillAttack.HurtList) |
| | | { |
| | | var bo = battleField.battleObjMgr.GetBattleObject((int)hurt.ObjID); |
| | | if (bo != null) targetSet.Add(bo); |
| | | |
| | | // 主目标的额外目标(弹射/平摊) |
| | | if (hurt.HurtListEx != null) |
| | | { |
| | | foreach (var hurtEx in hurt.HurtListEx) |
| | | { |
| | | var exBo = battleField.battleObjMgr.GetBattleObject((int)hurtEx.ObjID); |
| | | if (exBo != null) targetSet.Add(exBo); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 技能包顶层的 HurtListEx(如溅射、顶层平摊) |
| | | if (tagUseSkillAttack.HurtListEx != null) |
| | | { |
| | | foreach (var hurtEx in tagUseSkillAttack.HurtListEx) |
| | | { |
| | | var exBo = battleField.battleObjMgr.GetBattleObject((int)hurtEx.ObjID); |
| | | if (exBo != null) targetSet.Add(exBo); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 确保施法者也被高亮(原逻辑) |
| | | var highlightList = new List<BattleObject>(targetSet) { caster }; |
| | | |
| | | var allList = battleField.battleObjMgr.allBattleObjDict.Values.ToList(); |
| | | |
| | | // 构造集合便于判断 |
| | | var targetSetLookup = new HashSet<BattleObject>(targetSet); |
| | | var highlightSet = new HashSet<BattleObject>(highlightList); |
| | | |
| | | |
| | | // 先把施法者的 InfoBar 隐藏(原逻辑保留) |
| | | caster.heroInfoBar.SetActive(false); |
| | | |
| | | foreach (BattleObject bo in allList) |
| | | { |
| | | bool isHighlight = highlightSet.Contains(bo); |
| | | bool isTarget = targetSet.Contains(bo); |
| | | |
| | | bool isTarget = targetSetLookup.Contains(bo); |
| | | |
| | | if (isHighlight) |
| | | { |
| | | bo.layerMgr.SetFront(); |
| | |
| | | bo.layerMgr.SetBack(); |
| | | } |
| | | |
| | | // 目标(含 HurtListEx)都应显示 InfoBar |
| | | bo.heroInfoBar.SetActive(isTarget); |
| | | } |
| | | |
| | | battleField.battleRootNode.skillMaskNode.SetActive(true); |
| | | // battleField.battleRootNode.SetSortingOrder(); |
| | | } |
| | | |
| | | // 命中目标回调:处理所有被命中的目标 |
| | | protected long suckHp = 0; |
| | | |
| | | // 命中目标回调:处理所有被命中的目标(包括主目标、弹射目标、溅射目标) |
| | | protected virtual void OnHitTargets(int _hitIndex, List<HB427_tagSCUseSkill.tagSCUseSkillHurt> hitList) |
| | | { |
| | | // 造成伤害前先处理血量刷新包 |
| | | HandleRefreshHP(); |
| | | |
| | | suckHp = 0; |
| | | |
| | | // 统计吸血总量(主目标) |
| | | foreach (var hurt in hitList) |
| | | { |
| | | suckHp += hurt.SuckHP; |
| | | } |
| | | |
| | | // 处理主目标列表 |
| | | foreach (var hurt in hitList) |
| | | { |
| | | BattleObject target = caster.battleField.battleObjMgr.GetBattleObject((int)hurt.ObjID); |
| | | if (target == null) |
| | | { |
| | |
| | | } |
| | | |
| | | OnHitEachTarget(_hitIndex, target, hurt); |
| | | |
| | | // 处理该目标的额外目标列表(如弹射伤害的平摊目标) |
| | | if (hurt.HurtListEx != null && hurt.HurtListEx.Length > 0) |
| | | { |
| | | foreach (var hurtEx in hurt.HurtListEx) |
| | | { |
| | | BattleObject exTarget = caster.battleField.battleObjMgr.GetBattleObject((int)hurtEx.ObjID); |
| | | if (exTarget == null) |
| | | { |
| | | Debug.LogError($"额外目标为空 HurtListEx target == null ObjId : {hurtEx.ObjID}"); |
| | | continue; |
| | | } |
| | | |
| | | OnHitEachTargetEx(_hitIndex, exTarget, hurtEx); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 处理技能包顶层的额外目标列表(如溅射伤害、平摊伤害) |
| | | if (tagUseSkillAttack.HurtListEx != null && tagUseSkillAttack.HurtListEx.Length > 0) |
| | | { |
| | | foreach (var hurtEx in tagUseSkillAttack.HurtListEx) |
| | | { |
| | | BattleObject exTarget = caster.battleField.battleObjMgr.GetBattleObject((int)hurtEx.ObjID); |
| | | if (exTarget == null) |
| | | { |
| | | Debug.LogError($"顶层额外目标为空 tagUseSkillAttack.HurtListEx target == null ObjId : {hurtEx.ObjID}"); |
| | | continue; |
| | | } |
| | | |
| | | OnHitEachTargetEx(_hitIndex, exTarget, hurtEx); |
| | | } |
| | | } |
| | | |
| | | if (0 == _hitIndex) |
| | | { |
| | | bool needhint = false; |
| | | |
| | | for (int i = 0; i < hitList.Count; i++) |
| | | { |
| | | var hurt = hitList[i]; |
| | | |
| | | //8-击晕 |
| | | if ((hurt.AttackTypes & (int)DamageType.Stunned) == (int)DamageType.Stunned) |
| | | { |
| | | needhint = true; |
| | | break; |
| | | } |
| | | |
| | | for (int j = 0; j < hurt.HurtListEx?.Length; j++) |
| | | { |
| | | var hurtex = hurt.HurtListEx[j]; |
| | | //8-击晕 |
| | | if ((hurtex.AttackTypes & (int)ServerDamageType.Stunned) == (int)ServerDamageType.Stunned) |
| | | { |
| | | needhint = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (needhint) |
| | | break; |
| | | } |
| | | |
| | | if (needhint) |
| | | { |
| | | DamageNumConfig hintConfig = DamageNumConfig.Get(BattleConst.BattleStun); |
| | | Hint(caster, hintConfig); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | // 处理单个目标被命中:应用伤害和施法者效果 |
| | | protected virtual void OnHitEachTarget(int _hitIndex, BattleObject target, HB427_tagSCUseSkill.tagSCUseSkillHurt hurt) |
| | | { |
| | | // ============ 第一步:计算伤害分布 ============ |
| | | List<int> damageDivide = new List<int>(); |
| | | if (_hitIndex == 0 && skillConfig.DamageDivide.Length <= 0) |
| | | { |
| | | damageDivide.Add(10000); |
| | | } |
| | | else |
| | | { |
| | | if (skillConfig.DamageDivide.Length <= _hitIndex) |
| | | { |
| | | Debug.LogError("技能伤害分布配置错误 skillId: " + skillConfig.SkillID + " hitIndex: " + _hitIndex); |
| | | damageDivide.Add(10000); |
| | | } |
| | | else |
| | | { |
| | | damageDivide = skillConfig.DamageDivide[_hitIndex].ToList(); |
| | | } |
| | | } |
| | | |
| | | // 计算总伤害和分段伤害列表 |
| | | long totalDamage = GeneralDefine.GetFactValue(hurt.HurtHP, hurt.HurtHPEx); |
| | | List<long> damageList = BattleUtility.DivideDamageToList(skillConfig.DamageDivide, _hitIndex, totalDamage); |
| | | |
| | | // ============ 第二步:刷新实际血量 ============ |
| | | long fromHp = target.teamHero.curHp; |
| | | |
| | | |
| | | |
| | | // ============处理吸血跟反伤 =============== |
| | | // 也要按每一击平均算 最后要补齐伤害 |
| | | long suckHp = hurt.SuckHP; |
| | | long reflectHp = hurt.BounceHP; |
| | | |
| | | List<long> suckHpList = BattleUtility.DivideDamageToList(skillConfig.DamageDivide, _hitIndex, suckHp); |
| | | |
| | | List<long> reflectHpList = BattleUtility.DivideDamageToList(skillConfig.DamageDivide, _hitIndex, hurt.BounceHP); |
| | | // long currentSuckHp = suckHp / tagUseSkillAttack.HurtCount; |
| | | |
| | | // 计算当前这一击的实际伤害(所有分段伤害之和) |
| | | long currentHitDamage = 0; |
| | | foreach (long dmg in damageList) |
| | | { |
| | | currentHitDamage += dmg; |
| | | } |
| | | |
| | | long currentHitSuckHp = 0; |
| | | foreach (long suck in suckHpList) |
| | | { |
| | | currentHitSuckHp += suck; |
| | | } |
| | | |
| | | long currentHitReflectHp = 0; |
| | | foreach (long reflect in reflectHpList) |
| | | { |
| | | currentHitReflectHp += reflect; |
| | | } |
| | | |
| | | long toHp = Math.Max(0, fromHp - currentHitDamage + currentHitSuckHp - currentHitReflectHp); |
| | | |
| | | |
| | | // 更新目标血量 |
| | | target.teamHero.curHp = toHp; |
| | | |
| | | #if UNITY_EDITOR |
| | | BattleDebug.LogError( |
| | | (caster.Camp == BattleCamp.Red ? "【红方行动】" : "【蓝方行动】") + "\n" + |
| | | $"攻击者: {caster.teamHero.name}\n" + |
| | | $"目标: {target.teamHero.name}\n" + |
| | | $"技能: {skillConfig.SkillName} (第{_hitIndex}击)\n" + |
| | | $"伤害: {currentHitDamage} (总伤害: {totalDamage})\n" + |
| | | $"吸血: {currentHitSuckHp}\n" + |
| | | $"反伤: {currentHitReflectHp}\n" + |
| | | $"血量变化: {fromHp} -> {toHp}" |
| | | ); |
| | | #endif |
| | | |
| | | |
| | | bool isLastHit = _hitIndex >= skillConfig.DamageDivide.Length - 1; |
| | | |
| | | // ============ 第三步:获取临时数据(掉落、死亡等) ============ |
| | | // ============ 获取临时数据(掉落、死亡等) ============ |
| | | int objID = (int)target.ObjID; |
| | | tempDropList.TryGetValue(objID, out BattleDrops battleDrops); |
| | | tempDeadPackList.TryGetValue(objID, out HB422_tagMCTurnFightObjDead deadPack); |
| | | |
| | | // ============ 参数打包 ============ |
| | | BattleHurtParam hurtParam = BattleUtility.CalcBattleHurtParam(this, _hitIndex, target, hurt, battleDrops, deadPack); |
| | | |
| | | // 参数打包 |
| | | BattleHurtParam hurtParam = new BattleHurtParam() |
| | | #if UNITY_EDITOR |
| | | PrintHurtParamDebugInfo(hurtParam); |
| | | #endif |
| | | |
| | | // 先调用目标受伤 |
| | | target.Hurt(hurtParam); |
| | | |
| | | // 再调用施法者吸血/反伤 |
| | | caster.OnHurtTarget(hurtParam); |
| | | } |
| | | |
| | | // 处理额外目标被命中(HurtListEx):溅射、弹射、平摊伤害等 |
| | | protected virtual void OnHitEachTargetEx(int _hitIndex, BattleObject target, HB427_tagSCUseSkill.tagSCUseSkillHurtEx hurtEx) |
| | | { |
| | | // ============ 获取临时数据(掉落、死亡等) ============ |
| | | int objID = (int)target.ObjID; |
| | | tempDropList.TryGetValue(objID, out BattleDrops battleDrops); |
| | | tempDeadPackList.TryGetValue(objID, out HB422_tagMCTurnFightObjDead deadPack); |
| | | |
| | | // ============ 参数打包(将 tagSCUseSkillHurtEx 转换为 tagSCUseSkillHurt)============ |
| | | HB427_tagSCUseSkill.tagSCUseSkillHurt hurt = new HB427_tagSCUseSkill.tagSCUseSkillHurt |
| | | { |
| | | casterObj = caster, |
| | | hurtObj = target, |
| | | damageList = damageList, |
| | | suckHpList = suckHpList, |
| | | reflectHpList = reflectHpList, |
| | | fromHp = fromHp, |
| | | toHp = toHp, |
| | | battleDrops = battleDrops, |
| | | hurt = hurt, |
| | | hitIndex = _hitIndex, |
| | | deadPack = deadPack, |
| | | skillConfig = skillConfig |
| | | ObjID = hurtEx.ObjID, |
| | | AttackTypes = hurtEx.AttackTypes, |
| | | HurtHP = hurtEx.HurtHP, |
| | | HurtHPEx = hurtEx.HurtHPEx, |
| | | CurHP = hurtEx.CurHP, |
| | | CurHPEx = hurtEx.CurHPEx, |
| | | SuckHP = hurtEx.SuckHP, |
| | | BounceHP = 0, // HurtEx 没有反伤字段 |
| | | HurtCountEx = 0, |
| | | HurtListEx = null |
| | | }; |
| | | |
| | | // ============ 第四步:执行表现(飘字、动画等) ============ |
| | | BattleHurtParam hurtParam = BattleUtility.CalcBattleHurtParam(this, _hitIndex, target, hurt, battleDrops, deadPack); |
| | | |
| | | #if UNITY_EDITOR |
| | | PrintHurtParamDebugInfo(hurtParam); |
| | | #endif |
| | | |
| | | // 先调用目标受伤 |
| | | target.Hurt(hurtParam); |
| | | |
| | | |
| | | |
| | | // 再调用施法者吸血/反伤 |
| | | caster.OnHurtTarget(hurtParam); |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | private void PrintHurtParamDebugInfo(BattleHurtParam hurtParam) |
| | | { |
| | | bool isLastHit = hurtParam.hitIndex >= hurtParam.skillConfig.DamageDivide.Length - 1; |
| | | |
| | | long currentHitDamage = hurtParam.hurter.damageList != null ? hurtParam.hurter.damageList.Sum() : 0; |
| | | long currentHitSuckHp = hurtParam.caster.suckHpList != null ? hurtParam.caster.suckHpList.Sum() : 0; |
| | | long currentHitReflectHp = hurtParam.caster.reflectHpList != null ? hurtParam.caster.reflectHpList.Sum() : 0; |
| | | |
| | | long totalDamage = GeneralDefine.GetFactValue(hurtParam.hurt.HurtHP, hurtParam.hurt.HurtHPEx); |
| | | long totalSuckHp = BattleUtility.GetSuckHp(tagUseSkillAttack); |
| | | long totalReflectHp = hurtParam.hurt.BounceHP; |
| | | |
| | | BattleDebug.LogError( |
| | | (hurtParam.caster.casterObj.Camp == BattleCamp.Red ? "【红方行动】" : "【蓝方行动】 ") + |
| | | $"攻击者: {hurtParam.caster.casterObj.teamHero.name} (ObjID:{hurtParam.caster.casterObj.ObjID})\n" + |
| | | $"目标: {hurtParam.hurter.hurtObj.teamHero.name} (ObjID:{hurtParam.hurter.hurtObj.ObjID})\n" + |
| | | $"技能: {hurtParam.skillConfig.SkillName} (ID:{hurtParam.skillConfig.SkillID})\n" + |
| | | $"击数: 第{hurtParam.hitIndex + 1}击 / 共{hurtParam.skillConfig.DamageDivide.Length}击" + (isLastHit ? " [最后一击]" : " [中间击]") + "\n" + |
| | | $"\n" + |
| | | $"========== 目标受伤数据 ==========\n" + |
| | | $"伤害: {currentHitDamage} / 总伤害: {totalDamage}\n" + |
| | | $"伤害分段: [{string.Join(", ", hurtParam.hurter.damageList ?? new List<long>())}]\n" + |
| | | $"目标血量: {hurtParam.hurter.fromHp} -> {hurtParam.hurter.toHp} (最大:{hurtParam.hurter.maxHp})\n" + |
| | | $"目标护盾: {hurtParam.hurter.fromShieldValue} -> {hurtParam.hurter.toShieldValue}\n" + |
| | | $"攻击类型: {hurtParam.hurt.AttackTypes}\n" + |
| | | $"\n" + |
| | | $"========== 施法者数据 ==========\n" + |
| | | $"吸血: {currentHitSuckHp} / 总吸血: {totalSuckHp}\n" + |
| | | $"吸血分段: [{string.Join(", ", hurtParam.caster.suckHpList ?? new List<long>())}]\n" + |
| | | $"反伤: {currentHitReflectHp} / 总反伤: {totalReflectHp}\n" + |
| | | $"反伤分段: [{string.Join(", ", hurtParam.caster.reflectHpList ?? new List<long>())}]\n" + |
| | | $"施法者血量: {hurtParam.caster.fromHp} -> {hurtParam.caster.toHp} (最大:{hurtParam.caster.maxHp})\n" + |
| | | $"施法者护盾: {hurtParam.caster.fromShieldValue} -> {hurtParam.caster.toShieldValue}\n" |
| | | ); |
| | | } |
| | | #endif |
| | | |
| | | // 处理HP刷新包(简化逻辑) |
| | | private void HandleRefreshHP() |
| | |
| | | { |
| | | if (!isPlay) return false; |
| | | |
| | | bool tempRetValue = true; |
| | | |
| | | // 检查技能效果是否完成 |
| | | if (skillEffect != null) |
| | |
| | | if (!skillEffect.IsFinished()) return false; |
| | | skillEffect = null; |
| | | OnSkillFinished(); |
| | | return false; |
| | | tempRetValue = false; |
| | | } |
| | | |
| | | // 检查其他技能动作是否完成 |
| | |
| | | OnSkillFinished(); |
| | | } |
| | | } |
| | | if (otherSkillActionList.Count > 0) return false; |
| | | if (otherSkillActionList.Count > 0) |
| | | { |
| | | tempRetValue = false; |
| | | } |
| | | } |
| | | |
| | | if (!tempRetValue) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | // 检查最终完成状态 |
| | |
| | | if (pack is CustomHB426CombinePack combinePack && combinePack.startTag.Tag.StartsWith("Skill_")) |
| | | { |
| | | var otherSkillAction = combinePack.CreateSkillAction(); |
| | | otherSkillAction.fromSkillId = skillConfig.SkillID; |
| | | otherSkillAction.fromSkill = this; |
| | | otherSkillAction.ForceFinish(); |
| | | } |
| | | else |
| | |
| | | { |
| | | BattleDebug.LogError("other skill casting " + combinePack.startTag.Tag); |
| | | var otherSkillAction = combinePack.CreateSkillAction(); |
| | | otherSkillAction.fromSkillId = skillConfig.SkillID; |
| | | otherSkillAction.fromSkill = this; |
| | | otherSkillActionList.Add(otherSkillAction); |
| | | return false; |
| | | } |