| | |
| | | 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 SkillBase fromSkill; |
| | | public bool isPlay = false; |
| | | |
| | | // 父RecordAction(SkillRecordAction),用于子技能建立父子关系 |
| | | protected RecordAction parentRecordAction; |
| | | |
| | | // 技能动画是否播放完成(针对有动画的技能) |
| | | protected bool isMotionCompleted = false; |
| | | |
| | | private float MoveSpeed = 750f; |
| | | |
| | | private Dictionary<int, BattleDrops> tempDropList = new Dictionary<int, BattleDrops>(); |
| | | private Dictionary<int, BattleDeadPack> tempDeadPackList = new Dictionary<int, BattleDeadPack>(); |
| | | |
| | | protected List<HB428_tagSCBuffRefresh> buffCollections = new List<HB428_tagSCBuffRefresh>(); |
| | | // Buff相关包集合,支持 HB428(刷新) 和 HB429(删除) |
| | | protected List<GameNetPackBasic> buffPackCollections = new List<GameNetPackBasic>(); |
| | | |
| | | |
| | | // 构造函数:初始化技能基础数据 |
| | |
| | | battleField = _battleField; |
| | | packList = _packList; |
| | | |
| | | SafetyCheck(); |
| | | #if UNITY_EDITOR |
| | | if (Launch.Instance.isOpenSkillLogFile) |
| | | // 注册正在释放的技能 |
| | | if (battleField != null && caster != null) |
| | | { |
| | | PinrtHB427Hp(); |
| | | battleField.AddCastingSkill(caster.ObjID, this); |
| | | } |
| | | #endif |
| | | |
| | | SafetyCheck(); |
| | | } |
| | | |
| | | // 设置父RecordAction |
| | | public void SetParentRecordAction(RecordAction recordAction) |
| | | { |
| | | parentRecordAction = recordAction; |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | |
| | | |
| | | private void SafetyCheck() |
| | | { |
| | | #if UNITY_EDITOR |
| | | if (Launch.Instance.isOpenSkillLogFile) |
| | | { |
| | | PinrtHB427Hp(); |
| | | } |
| | | #endif |
| | | |
| | | bool safety = caster != null |
| | | && skillConfig != null |
| | | && tagUseSkillAttack != null |
| | |
| | | |
| | | skillEffect = SkillEffectFactory.CreateSkillEffect(this, caster, skillConfig, tagUseSkillAttack); |
| | | skillEffect.Play(OnHitTargets); |
| | | ProcessSubSkill(); |
| | | |
| | | isPlay = true; |
| | | } |
| | | |
| | | protected void ProcessSubSkill() |
| | | { |
| | | // 按packUID排序所有子技能 |
| | | var allSubSkills = new List<(ulong packUID, SkillRecordAction action)>(); |
| | | |
| | | 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); |
| | | if (recordAction != null) |
| | | { |
| | | recordAction.fromSkill = this; |
| | | allSubSkills.Add((subSkillPack.packUID, 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); |
| | | if (recordAction != null) |
| | | { |
| | | recordAction.fromSkill = this; |
| | | ulong packUID = subCombinePack.packList.Count > 0 ? GetPackUID(subCombinePack.packList[0]) : 0; |
| | | allSubSkills.Add((packUID, recordAction)); |
| | | } |
| | | } |
| | | tagUseSkillAttack.subSkillCombinePackList.Clear(); |
| | | |
| | | isPlay = true; |
| | | // 按packUID排序 |
| | | allSubSkills.Sort((a, b) => a.packUID.CompareTo(b.packUID)); |
| | | |
| | | // 依次添加到recordPlayer,每个等待前一个完成 |
| | | RecordAction waitingRecordAction = null; |
| | | foreach (var (packUID, recordAction) in allSubSkills) |
| | | { |
| | | // 【使用 BattleField.recordPlayer】 |
| | | // 原因:子技能是独立的SkillRecordAction,应该是顶层RecordAction,由BattleField的主RecordPlayer管理 |
| | | // 通过设置父子关系和WaitingPlay,可以控制子技能的执行时机 |
| | | if (waitingRecordAction != null) |
| | | { |
| | | // 每个都应该等前一个结束后 |
| | | battleField.recordPlayer.ImmediatelyPlay(recordAction, waitingRecordAction, true); |
| | | } |
| | | else |
| | | { |
| | | battleField.recordPlayer.ImmediatelyPlay(recordAction, parentRecordAction, true); |
| | | } |
| | | |
| | | if (recordAction.IsNeedWaiting()) |
| | | { |
| | | waitingRecordAction = recordAction; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 技能前摇结束回调 |
| | |
| | | // 技能中摇开始回调:通知技能效果处理中摇开始 |
| | | public virtual void OnMiddleFrameStart(int times) |
| | | { |
| | | skillEffect?.OnMiddleFrameStart(times); // 修复:添加空值检查 |
| | | skillEffect.OnMiddleFrameStart(times); // 修复:添加空值检查 |
| | | } |
| | | |
| | | // 技能中摇结束回调:通知技能效果处理中摇结束 |
| | | public virtual void OnMiddleFrameEnd(int times, int hitIndex) |
| | | { |
| | | skillEffect?.OnMiddleFrameEnd(times, hitIndex); // 修复:添加空值检查 |
| | | skillEffect.OnMiddleFrameEnd(times, hitIndex); // 修复:添加空值检查 |
| | | } |
| | | |
| | | // 技能后摇开始回调:通知技能效果处理后摇开始 |
| | | public virtual void OnFinalFrameStart() |
| | | { |
| | | skillEffect?.OnFinalFrameStart(); // 修复:添加空值检查 |
| | | skillEffect.OnFinalFrameStart(); // 修复:添加空值检查 |
| | | } |
| | | |
| | | // 技能后摇结束回调:通知技能效果处理后摇结束 |
| | | public virtual void OnFinalFrameEnd() |
| | | { |
| | | // 标记动画播放完成 |
| | | isMotionCompleted = true; |
| | | BattleDebug.LogError($"SkillBase.OnFinalFrameEnd: 技能 {skillConfig?.SkillID} 动画播放完成"); |
| | | |
| | | skillEffect?.OnFinalFrameEnd(); // 修复:添加空值检查 |
| | | } |
| | |
| | | // 高亮所有相关目标:设置施法者和目标的显示层级 |
| | | protected void HighLightAllTargets() |
| | | { |
| | | caster.layerMgr.SetSortingOrder(BattleConst.ActiveHeroActionSortingOrder); |
| | | caster.layerMgr.SetSortingOrder(BattleConst.SkillMaskOrder + BattleConst.BattleActiveHeroOffset); |
| | | |
| | | if (skillConfig.FuncType != 2) |
| | | return; |
| | |
| | | battleField.battleRootNode.skillMaskNode.SetActive(true); |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | bool suckHp = true; |
| | | |
| | | // 处理主目标列表 |
| | | foreach (var hurt in hitList) |
| | |
| | | continue; |
| | | } |
| | | |
| | | OnHitEachTarget(_hitIndex, target, hurt); |
| | | OnHitEachTarget(_hitIndex, target, hurt, suckHp); |
| | | |
| | | suckHp = false; |
| | | |
| | | // 处理该目标的额外目标列表(如弹射伤害的平摊目标) |
| | | if (hurt.HurtListEx != null && hurt.HurtListEx.Length > 0) |
| | |
| | | } |
| | | } |
| | | |
| | | HandleHint(_hitIndex, hitList); |
| | | } |
| | | |
| | | protected void HandleHint(int _hitIndex, List<HB427_tagSCUseSkill.tagSCUseSkillHurt> hitList) |
| | | { |
| | | if (0 == _hitIndex) |
| | | { |
| | | bool needhint = false; |
| | |
| | | DamageNumConfig hintConfig = DamageNumConfig.Get(BattleConst.BattleStun); |
| | | Hint(caster, hintConfig); |
| | | } |
| | | } |
| | | |
| | | |
| | | for (int i = 0; i < hitList.Count; i++) |
| | | { |
| | | var hurt = hitList[i]; |
| | | |
| | | if ((hurt.AttackTypes & (int)DamageType.BreakArmor) == (int)DamageType.BreakArmor) |
| | | { |
| | | BattleObject battleObject = caster.battleField.battleObjMgr.GetBattleObject((int)hurt.ObjID); |
| | | if (battleObject != null) |
| | | { |
| | | DamageNumConfig hintConfig = DamageNumConfig.Get(BattleConst.BreakArmor); |
| | | Hint(battleObject, hintConfig); |
| | | battleField.battleEffectMgr.PlayEffect(battleObject, |
| | | BattleConst.BreakArmorEffectID, battleObject.heroRectTrans, battleObject.Camp, |
| | | battleObject.teamHero.modelScale); |
| | | } |
| | | } |
| | | else if ((hurt.AttackTypes & (int)DamageType.Parry) == (int)DamageType.Parry) |
| | | { |
| | | BattleObject battleObject = caster.battleField.battleObjMgr.GetBattleObject((int)hurt.ObjID); |
| | | if (battleObject != null) |
| | | { |
| | | DamageNumConfig hintConfig = DamageNumConfig.Get(BattleConst.Parry); |
| | | Hint(battleObject, hintConfig); |
| | | battleField.battleEffectMgr.PlayEffect(battleObject, |
| | | BattleConst.ParryEffectID, battleObject.heroRectTrans, battleObject.Camp, |
| | | battleObject.teamHero.modelScale); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 处理单个目标被命中:应用伤害和施法者效果 |
| | | protected virtual void OnHitEachTarget(int _hitIndex, BattleObject target, HB427_tagSCUseSkill.tagSCUseSkillHurt hurt) |
| | | protected virtual void OnHitEachTarget(int _hitIndex, BattleObject target, HB427_tagSCUseSkill.tagSCUseSkillHurt hurt, bool suckHp) |
| | | { |
| | | // ============ 获取临时数据(掉落、死亡等) ============ |
| | | int objID = (int)target.ObjID; |
| | | tempDropList.TryGetValue(objID, out BattleDrops battleDrops); |
| | | tempDeadPackList.TryGetValue(objID, out BattleDeadPack deadPack); |
| | | |
| | | bool clearSuckHp = tagUseSkillAttack.HurtList.ToList().IndexOf(hurt) != 0; |
| | | // 如果目标正在释放技能,跳过死亡处理(延迟到技能结束) |
| | | if (battleField != null && battleField.IsCastingSkill(target.ObjID)) |
| | | { |
| | | deadPack = null; |
| | | } |
| | | |
| | | // ============ 参数打包 ============ |
| | | BattleHurtParam hurtParam = BattleUtility.CalcBattleHurtParam(this, _hitIndex, target, hurt, battleDrops, deadPack); |
| | | if (clearSuckHp) |
| | | { |
| | | hurtParam.caster.suckHpList.Clear(); |
| | | } |
| | | BattleHurtParam hurtParam = BattleUtility.CalcBattleHurtParam(this, _hitIndex, target, hurt, battleDrops, deadPack, suckHp); |
| | | #if UNITY_EDITOR |
| | | PrintHurtParamDebugInfo(hurtParam); |
| | | #endif |
| | | |
| | | // 先调用目标受伤 |
| | | target.Hurt(hurtParam); |
| | | target.Hurt(hurtParam, parentRecordAction); |
| | | |
| | | // 再调用施法者吸血/反伤 |
| | | caster.OnHurtTarget(hurtParam); |
| | |
| | | // ============ 获取临时数据(掉落、死亡等) ============ |
| | | int objID = (int)target.ObjID; |
| | | tempDropList.TryGetValue(objID, out BattleDrops battleDrops); |
| | | |
| | | tempDeadPackList.TryGetValue(objID, out BattleDeadPack deadPack); |
| | | |
| | | // 如果目标正在释放技能,跳过死亡处理(延迟到技能结束) |
| | | if (battleField != null && battleField.IsCastingSkill(target.ObjID)) |
| | | { |
| | | deadPack = null; |
| | | } |
| | | // ============ 参数打包(将 tagSCUseSkillHurtEx 转换为 tagSCUseSkillHurt)============ |
| | | HB427_tagSCUseSkill.tagSCUseSkillHurt hurt = new HB427_tagSCUseSkill.tagSCUseSkillHurt |
| | | { |
| | |
| | | HurtHPEx = hurtEx.HurtHPEx, |
| | | CurHP = hurtEx.CurHP, |
| | | CurHPEx = hurtEx.CurHPEx, |
| | | SuckHP = hurtEx.SuckHP, |
| | | SuckHP = 0,//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); |
| | | OnHitEachTarget(_hitIndex, target, hurt, false);//获取全部吸血时已经计算过 这里就不再计算 |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | |
| | | if (refreshPack != null) |
| | | { |
| | | // 分发HP刷新包 |
| | | PackageRegedit.Distribute(refreshPack); |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | | // 原因:HP刷新包是技能内部产生的,应该由当前SkillRecordAction的innerRecordPlayer管理 |
| | | // 这样可以确保HP刷新与技能的生命周期绑定,ForceFinish时一并处理 |
| | | PackageRegeditEx.DistributeToRecordAction(refreshPack, parentRecordAction); |
| | | packList.Remove(refreshPack); |
| | | } |
| | | } |
| | |
| | | List<BattleDeadPack> deadPackList = BattleUtility.FindDeadPack(packList); |
| | | if (deadPackList.Count <= 0) return; |
| | | |
| | | // 找到最大的死亡包 packUID(包括死亡包和死亡触发技能) |
| | | ulong maxDeathPackUID = 0; |
| | | foreach (var deadPack in deadPackList) |
| | | { |
| | | if (deadPack.deadPack != null && deadPack.deadPack.packUID > maxDeathPackUID) |
| | | { |
| | | maxDeathPackUID = deadPack.deadPack.packUID; |
| | | } |
| | | |
| | | if (deadPack.deadTriggerSkill != null) |
| | | { |
| | | var skillPack = deadPack.deadTriggerSkill.GetMainHB427SkillPack(); |
| | | if (skillPack != null && skillPack.packUID > maxDeathPackUID) |
| | | { |
| | | maxDeathPackUID = skillPack.packUID; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 如果找到了死亡包,收集所有 packUID > maxDeathPackUID 的包 |
| | | if (maxDeathPackUID > 0) |
| | | { |
| | | BattleDebug.LogError($"SkillBase.HandleDead: 找到死亡包,maxDeathPackUID = {maxDeathPackUID},开始收集死亡后的包"); |
| | | |
| | | // 1. 收集 packList 中 packUID 大于死亡包的包 |
| | | List<GameNetPackBasic> packsToRemove = new List<GameNetPackBasic>(); |
| | | foreach (var pack in packList) |
| | | { |
| | | ulong packUID = GetPackUID(pack); |
| | | if (packUID > maxDeathPackUID) |
| | | { |
| | | BattleDebug.LogError($"SkillBase.HandleDead: 从packList收集死亡后的包 - Type: {pack.GetType().Name}, UID: {packUID}"); |
| | | foreach (var deadPack in deadPackList) |
| | | { |
| | | deadPack.packListAfterDeath.Add(pack); |
| | | } |
| | | packsToRemove.Add(pack); |
| | | } |
| | | } |
| | | |
| | | // 从 packList 中移除这些包 |
| | | foreach (var pack in packsToRemove) |
| | | { |
| | | packList.Remove(pack); |
| | | } |
| | | |
| | | // 2. 收集 subSkillList 中 packUID 大于死亡包的子技能 |
| | | if (tagUseSkillAttack.subSkillList != null && tagUseSkillAttack.subSkillList.Count > 0) |
| | | { |
| | | var subSkillsToRemove = new List<HB427_tagSCUseSkill>(); |
| | | foreach (var subSkillPack in tagUseSkillAttack.subSkillList) |
| | | { |
| | | ulong subSkillUID = GetPackUID(subSkillPack); |
| | | if (subSkillUID > maxDeathPackUID) |
| | | { |
| | | BattleDebug.LogError($"SkillBase.HandleDead: 从subSkillList收集死亡后的包 - Type: {subSkillPack.GetType().Name}, UID: {subSkillUID}"); |
| | | foreach (var deadPack in deadPackList) |
| | | { |
| | | deadPack.packListAfterDeath.Add(subSkillPack); |
| | | } |
| | | subSkillsToRemove.Add(subSkillPack); |
| | | } |
| | | } |
| | | |
| | | // 从 subSkillList 中移除这些子技能 |
| | | foreach (var subSkill in subSkillsToRemove) |
| | | { |
| | | tagUseSkillAttack.subSkillList.Remove(subSkill); |
| | | } |
| | | } |
| | | |
| | | // 3. 收集 subSkillCombinePackList 中 packUID 大于死亡包的组合包 |
| | | if (tagUseSkillAttack.subSkillCombinePackList != null && tagUseSkillAttack.subSkillCombinePackList.Count > 0) |
| | | { |
| | | var combinePacksToRemove = new List<CustomHB426CombinePack>(); |
| | | foreach (var subCombinePack in tagUseSkillAttack.subSkillCombinePackList) |
| | | { |
| | | // 找到组合包中的最小 packUID(组合包的 packUID 以第一个包为准) |
| | | ulong combinePackUID = 0; |
| | | if (subCombinePack.packList != null && subCombinePack.packList.Count > 0) |
| | | { |
| | | combinePackUID = GetPackUID(subCombinePack.packList[0]); |
| | | } |
| | | |
| | | if (combinePackUID > maxDeathPackUID) |
| | | { |
| | | BattleDebug.LogError($"SkillBase.HandleDead: 从subSkillCombinePackList收集死亡后的包 - UID: {combinePackUID}, 包含 {subCombinePack.packList.Count} 个子包"); |
| | | // 将组合包中的所有包都添加到 packListAfterDeath |
| | | foreach (var pack in subCombinePack.packList) |
| | | { |
| | | foreach (var deadPack in deadPackList) |
| | | { |
| | | deadPack.packListAfterDeath.Add(pack); |
| | | } |
| | | } |
| | | combinePacksToRemove.Add(subCombinePack); |
| | | } |
| | | } |
| | | |
| | | // 从 subSkillCombinePackList 中移除这些组合包 |
| | | foreach (var combinePack in combinePacksToRemove) |
| | | { |
| | | tagUseSkillAttack.subSkillCombinePackList.Remove(combinePack); |
| | | } |
| | | } |
| | | } |
| | | |
| | | CheckAfterDeadhPack(); |
| | | |
| | | // 修复:先收集要删除的包,避免在foreach中修改集合 |
| | | var dropPacksToRemove = new List<H0704_tagRolePackRefresh>(dropPackList); |
| | | foreach (var _dropPack in dropPacksToRemove) |
| | | { |
| | | PackageRegedit.Distribute(_dropPack); |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | | // 原因:掉落包是技能效果的一部分,应该由当前SkillRecordAction管理 |
| | | // 掉落包的分发与技能完成绑定,确保在技能ForceFinish时正确处理 |
| | | PackageRegeditEx.DistributeToRecordAction(_dropPack, parentRecordAction); |
| | | packList.Remove(_dropPack); |
| | | } |
| | | |
| | |
| | | for (int i = 0; i < itemList.Count; i++) |
| | | dropAssign[i % deadCount].Add(itemList[i]); |
| | | return dropAssign; |
| | | } |
| | | |
| | | // 获取包的 packUID |
| | | protected ulong GetPackUID(GameNetPackBasic pack) |
| | | { |
| | | if (pack == null) return 0; |
| | | |
| | | if (pack is HB422_tagMCTurnFightObjDead deadPack) |
| | | return deadPack.packUID; |
| | | |
| | | if (pack is CustomHB426CombinePack combinePack) |
| | | { |
| | | var mainSkillPack = combinePack.GetMainHB427SkillPack(); |
| | | return mainSkillPack?.packUID ?? 0; |
| | | } |
| | | |
| | | if (pack is HB427_tagSCUseSkill skillPack) |
| | | return skillPack.packUID; |
| | | |
| | | if (pack is HB428_tagSCBuffRefresh buffRefresh) |
| | | return buffRefresh.packUID; |
| | | |
| | | if (pack is HB429_tagSCBuffDel buffDel) |
| | | return buffDel.packUID; |
| | | |
| | | if (pack is HB419_tagSCObjHPRefresh hpRefresh) |
| | | return hpRefresh.packUID; |
| | | |
| | | if (pack is HB405_tagMCAddExp expPack) |
| | | return expPack.packUID; |
| | | |
| | | if (pack is H0704_tagRolePackRefresh dropPack) |
| | | return dropPack.packUID; |
| | | |
| | | // 尝试通过反射获取 packUID |
| | | var packUIDField = pack.GetType().GetField("packUID"); |
| | | if (packUIDField != null) |
| | | { |
| | | return (ulong)packUIDField.GetValue(pack); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | // 分配经验值:将经验包平均分配给每个死亡对象 |
| | |
| | | return false; |
| | | } |
| | | |
| | | // 如果技能有动画(SkillMotionName不为空),需要等待动画播放完成 |
| | | if (skillConfig != null && !string.IsNullOrEmpty(skillConfig.SkillMotionName)) |
| | | { |
| | | if (!isMotionCompleted) |
| | | { |
| | | BattleDebug.LogError($"SkillBase.IsFinishedForJudge: 技能 {skillConfig.SkillID} 等待动画播放完成"); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | // 技能完全结束,移除技能注册并触发延迟的死亡判定 |
| | | if (battleField != null && caster != null) |
| | | { |
| | | battleField.RemoveCastingSkill(caster.ObjID, this); |
| | | |
| | | // 传递parentRecordAction,让死亡技能等待当前技能完成 |
| | | battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values)); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | if (isFinished) |
| | | return; |
| | | |
| | | // 移除技能注册 |
| | | if (battleField != null && caster != null) |
| | | { |
| | | battleField.RemoveCastingSkill(caster.ObjID, this); |
| | | } |
| | | |
| | | // 传递parentRecordAction,让死亡技能等待当前技能完成 |
| | | battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values)); |
| | | |
| | | // 1. 强制结束技能效果 |
| | | skillEffect?.ForceFinished(); |
| | | skillEffect = null; |
| | | |
| | | foreach (var subSkillPack in tagUseSkillAttack.subSkillList) |
| | | { |
| | | SkillRecordAction recordAction = CustomHB426CombinePack.CreateSkillAction(battleField.guid, new List<GameNetPackBasic>() { subSkillPack }); |
| | | recordAction.fromSkill = this; |
| | | otherSkillActionList.Add(recordAction); |
| | | |
| | | // 【使用 BattleField.recordPlayer】 |
| | | // 原因:即使在ForceFinished中,子技能也是顶层RecordAction,应该由主RecordPlayer管理 |
| | | // 这些子技能会立即被ForceFinish,但仍需要正确的播放器上下文 |
| | | battleField.recordPlayer.ImmediatelyPlay(recordAction, parentRecordAction, true); |
| | | } |
| | | 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】 |
| | | // 原因:即使在ForceFinished中,子技能也是顶层RecordAction,应该由主RecordPlayer管理 |
| | | battleField.recordPlayer.ImmediatelyPlay(recordAction, parentRecordAction, true); |
| | | } |
| | | tagUseSkillAttack.subSkillCombinePackList.Clear(); |
| | | |
| | | // 2. 强制结束所有子技能动作 |
| | | otherSkillActionList.ForEach(action => action.ForceFinish()); |
| | | otherSkillActionList.Clear(); |
| | | |
| | | // 3. 清理 DOTween 动画(防止移动回调在战斗结束后执行) |
| | | if (caster != null && caster.heroRectTrans != null) |
| | | { |
| | | DG.Tweening.DOTween.Kill(caster.heroRectTrans); |
| | | } |
| | | |
| | | // 4. 重置施法者状态 |
| | | if (caster != null) |
| | | { |
| | | // 重置位置到原点 |
| | | if (caster.heroRectTrans != null) |
| | | { |
| | | caster.heroRectTrans.anchoredPosition = Vector2.zero; |
| | | } |
| | | |
| | | // 重置朝向 |
| | | if (caster.heroGo != null) |
| | | { |
| | | Vector3 scale = caster.heroGo.transform.localScale; |
| | | scale.x = Mathf.Abs(scale.x); |
| | | caster.heroGo.transform.localScale = scale; |
| | | } |
| | | |
| | | // 取消幻影效果 |
| | | caster.motionBase?.ShowIllusionShadow(false); |
| | | |
| | | // 播放待机动画(如果还活着) |
| | | if (!caster.teamHero.isDead) |
| | | { |
| | | caster.motionBase?.ResetForReborn(false); |
| | | } |
| | | } |
| | | |
| | | // 5. 恢复 UI 状态 |
| | | if (battleField != null) |
| | | { |
| | | // 恢复所有角色的显示层级和血条 |
| | | var allList = battleField.battleObjMgr?.allBattleObjDict?.Values; |
| | | if (allList != null) |
| | | { |
| | | foreach (BattleObject bo in allList) |
| | | { |
| | | bo.layerMgr?.SetFront(); |
| | | bo.heroInfoBar?.SetActive(true); |
| | | } |
| | | } |
| | | |
| | | // 关闭技能遮罩 |
| | | if (battleField.battleRootNode != null && battleField.battleRootNode.skillMaskNode != null) |
| | | { |
| | | battleField.battleRootNode.skillMaskNode.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | isFinished = true; |
| | | moveFinished = true; |
| | | isPlay = true; |
| | | |
| | | // 强制结束时,无论是否有动画,都标记动画完成 |
| | | isMotionCompleted = true; |
| | | |
| | | // 处理所有剩余包 |
| | | // 6. 处理所有剩余包(包括 buff 包) |
| | | // 先处理 buffPackCollections |
| | | DistributeBuffPacks(buffPackCollections); |
| | | buffPackCollections.Clear(); |
| | | |
| | | // 处理剩余的 packList |
| | | while (packList.Count > 0) |
| | | { |
| | | var pack = packList[0]; |
| | |
| | | { |
| | | if (pack is CustomB421ActionPack actionPack) |
| | | actionPack.Distribute(); |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | | // 原因:ForceFinished时剩余的包也是技能内部产生的,应该由innerRecordPlayer管理 |
| | | // 这样可以确保即使强制结束,包的处理也在正确的上下文中 |
| | | PackageRegedit.Distribute(pack); |
| | | } |
| | | } |
| | |
| | | otherSkillActionList.Add(otherSkillAction); |
| | | return false; |
| | | } |
| | | else if (pack is HB428_tagSCBuffRefresh buffRefresh) |
| | | else if (IsBuffPack(pack)) |
| | | { |
| | | // 从找到第一个HB428开始 找出连续的HB428_tagSCBuffRefresh包 如果找到一个B428后 之后碰到非HB428包就停止 |
| | | buffCollections.Add(buffRefresh); |
| | | // 从找到第一个 Buff 包开始,收集连续的 HB428/HB429 包 |
| | | buffPackCollections.Add(pack); |
| | | while (packList.Count > 0) |
| | | { |
| | | var nextPack = packList[0]; |
| | | if (nextPack is HB428_tagSCBuffRefresh nextBuffRefresh) |
| | | if (IsBuffPack(nextPack)) |
| | | { |
| | | buffCollections.Add(nextBuffRefresh); |
| | | buffPackCollections.Add(nextPack); |
| | | packList.RemoveAt(0); |
| | | } |
| | | else |
| | |
| | | } |
| | | } |
| | | |
| | | // 同时刷新所有对象的buff,不分组 |
| | | foreach (var buff in buffCollections) |
| | | { |
| | | BattleObject battleObj = battleField.battleObjMgr.GetBattleObject((int)buff.ObjID); |
| | | if (battleObj != null) |
| | | { |
| | | battleObj.buffMgr.RefreshBuff(buff, true); |
| | | } |
| | | } |
| | | // 处理所有收集到的 buff 包 |
| | | ProcessBuffPacks(buffPackCollections); |
| | | |
| | | // 清空已处理的buff集合 |
| | | buffCollections.Clear(); |
| | | // 清空已处理的 buff 集合 |
| | | buffPackCollections.Clear(); |
| | | continue; |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | PackageRegedit.Distribute(pack); |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | | // 原因:技能执行过程中的包(Buff、属性刷新等)是技能效果的一部分 |
| | | // 应该由SkillRecordAction的innerRecordPlayer管理,确保与技能生命周期一致 |
| | | PackageRegeditEx.DistributeToRecordAction(pack, parentRecordAction); |
| | | } |
| | | } |
| | | |
| | |
| | | otherSkillActionList?.Clear(); |
| | | dropPackList?.Clear(); |
| | | expPackList?.Clear(); |
| | | buffPackCollections?.Clear(); |
| | | |
| | | skillEffect = null; |
| | | packList = null; |
| | | } |
| | | |
| | | #region Buff包处理 |
| | | |
| | | /// <summary> |
| | | /// 判断是否为 Buff 相关的包(HB428 或 HB429) |
| | | /// </summary> |
| | | protected bool IsBuffPack(GameNetPackBasic pack) |
| | | { |
| | | return pack is HB428_tagSCBuffRefresh || pack is HB429_tagSCBuffDel; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 处理收集到的 Buff 包列表(HB428 刷新 和 HB429 删除) |
| | | /// </summary> |
| | | protected void ProcessBuffPacks(List<GameNetPackBasic> buffPacks) |
| | | { |
| | | if (buffPacks == null || buffPacks.Count == 0) return; |
| | | |
| | | foreach (var pack in buffPacks) |
| | | { |
| | | if (pack is HB428_tagSCBuffRefresh buffRefresh) |
| | | { |
| | | BattleObject battleObj = battleField.battleObjMgr.GetBattleObject((int)buffRefresh.ObjID); |
| | | if (battleObj != null) |
| | | { |
| | | battleObj.buffMgr.RefreshBuff(buffRefresh, true); |
| | | } |
| | | } |
| | | else if (pack is HB429_tagSCBuffDel buffDel) |
| | | { |
| | | BattleObject battleObj = battleField.battleObjMgr.GetBattleObject((int)buffDel.ObjID); |
| | | if (battleObj != null) |
| | | { |
| | | battleObj.buffMgr.RemoveBuff(buffDel, false); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 强制分发 Buff 包(用于 ForceFinished 场景) |
| | | /// </summary> |
| | | protected void DistributeBuffPacks(List<GameNetPackBasic> buffPacks) |
| | | { |
| | | if (buffPacks == null || buffPacks.Count == 0) return; |
| | | |
| | | foreach (var pack in buffPacks) |
| | | { |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | | // 原因:Buff包是技能效果的核心组成部分,应该由SkillRecordAction管理 |
| | | // 即使是强制分发的情况,也要保持在正确的RecordAction上下文中 |
| | | PackageRegeditEx.DistributeToRecordAction(pack, parentRecordAction); |
| | | } |
| | | } |
| | | |
| | | public virtual bool CanStartExecution() |
| | | { |
| | | if (null == caster) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | if (null == skillConfig) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(skillConfig.SkillMotionName)) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | return !battleField.IsCastingSkill(caster.ObjID); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | } |