| | |
| | | protected RectTransform targetNode = null; // 目标节点 |
| | | public BattleObject caster = null; // 施法者 |
| | | protected List<GameNetPackBasic> packList; |
| | | protected List<SkillRecordAction> otherSkillActionList = new List<SkillRecordAction>(); |
| | | |
| | | protected List<RecordAction> currentWaitingSkill = new List<RecordAction>(); |
| | | |
| | | protected List<H0704_tagRolePackRefresh> dropPackList = new List<H0704_tagRolePackRefresh>(); |
| | | protected List<HB405_tagMCAddExp> expPackList = new List<HB405_tagMCAddExp>(); |
| | | |
| | |
| | | } |
| | | |
| | | SafetyCheck(); |
| | | } |
| | | |
| | | public virtual void AfterAddToQueue() |
| | | { |
| | | |
| | | } |
| | | |
| | | // 设置父RecordAction |
| | |
| | | return; |
| | | } |
| | | |
| | | if (otherSkillActionList.Count > 0) |
| | | { |
| | | for (int i = otherSkillActionList.Count - 1; i >= 0; i--) |
| | | { |
| | | var action = otherSkillActionList[i]; |
| | | if (action.IsFinished()) |
| | | { |
| | | otherSkillActionList.RemoveAt(i); |
| | | OnSkillFinished(); |
| | | } |
| | | else if (moveFinished) |
| | | { |
| | | action.Run(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | protected void ShadowIllutionCreate(bool create) |
| | |
| | | return; |
| | | } |
| | | |
| | | ProcessSubSkill(); |
| | | |
| | | HandleDead(); |
| | | |
| | | skillEffect = SkillEffectFactory.CreateSkillEffect(this, caster, skillConfig, tagUseSkillAttack); |
| | | skillEffect.Play(OnHitTargets); |
| | | ProcessSubSkill(); |
| | | |
| | | |
| | | isPlay = true; |
| | | } |
| | |
| | | // 按packUID排序所有子技能 |
| | | var allSubSkills = new List<(ulong packUID, SkillRecordAction action)>(); |
| | | |
| | | foreach (var subSkillPack in tagUseSkillAttack.subSkillList) |
| | | List<GameNetPackBasic> removePackList = new List<GameNetPackBasic>(); |
| | | |
| | | foreach (var pack in packList) |
| | | { |
| | | SkillRecordAction recordAction = CustomHB426CombinePack.CreateSkillAction(battleField.guid, new List<GameNetPackBasic>() { subSkillPack }); |
| | | if (recordAction != null) |
| | | if (pack is HB427_tagSCUseSkill skillPack) |
| | | { |
| | | recordAction.fromSkill = this; |
| | | allSubSkills.Add((subSkillPack.packUID, recordAction)); |
| | | SkillConfig ssc = SkillConfig.Get((int)skillPack.SkillID); |
| | | if (!string.IsNullOrEmpty(ssc.SkillMotionName)) |
| | | { |
| | | break; |
| | | } |
| | | SkillRecordAction skillRecordAction = CustomHB426CombinePack.CreateSkillAction(battleField.guid, new List<GameNetPackBasic> { skillPack }); |
| | | allSubSkills.Add((skillPack.packUID, skillRecordAction)); |
| | | removePackList.Add(pack); |
| | | } |
| | | else if (pack is HB422_tagMCTurnFightObjDead dead) |
| | | { |
| | | break; |
| | | } |
| | | else if (pack is CustomHB426CombinePack combinePack) |
| | | { |
| | | HB427_tagSCUseSkill sp = combinePack.GetMainHB427SkillPack(); |
| | | SkillConfig ssc = SkillConfig.Get((int)sp.SkillID); |
| | | |
| | | if (!string.IsNullOrEmpty(ssc.SkillMotionName)) |
| | | { |
| | | break; |
| | | } |
| | | SkillRecordAction skillRecordAction = combinePack.CreateSkillAction(); |
| | | allSubSkills.Add((sp.packUID, skillRecordAction)); |
| | | removePackList.Add(pack); |
| | | } |
| | | } |
| | | tagUseSkillAttack.subSkillList.Clear(); |
| | | |
| | | foreach (var subCombinePack in tagUseSkillAttack.subSkillCombinePackList) |
| | | |
| | | for (int i = 0; i < removePackList.Count; i++) |
| | | { |
| | | SkillRecordAction recordAction = CustomHB426CombinePack.CreateSkillAction(battleField.guid, subCombinePack.packList); |
| | | if (recordAction != null) |
| | | { |
| | | recordAction.fromSkill = this; |
| | | ulong packUID = subCombinePack.packList.Count > 0 ? GetPackUID(subCombinePack.packList[0]) : 0; |
| | | allSubSkills.Add((packUID, recordAction)); |
| | | } |
| | | packList.Remove(removePackList[i]); |
| | | } |
| | | tagUseSkillAttack.subSkillCombinePackList.Clear(); |
| | | |
| | | // 按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; |
| | | } |
| | | battleField.recordPlayer.ImmediatelyPlay(recordAction); |
| | | currentWaitingSkill.Add(recordAction); |
| | | } |
| | | } |
| | | |
| | |
| | | #endif |
| | | |
| | | // 先调用目标受伤 |
| | | target.Hurt(hurtParam, parentRecordAction); |
| | | var recordAc = target.Hurt(hurtParam, parentRecordAction); |
| | | |
| | | if (null != recordAc) |
| | | { |
| | | tempDeadPackList.Remove(hurtParam.hurter.hurtObj.ObjID); |
| | | battleField.recordPlayer.ImmediatelyPlay(recordAc, parentRecordAction, true); |
| | | currentWaitingSkill.Add(recordAc); |
| | | } |
| | | |
| | | // 再调用施法者吸血/反伤 |
| | | caster.OnHurtTarget(hurtParam); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | if (!skillEffect.IsFinished()) return false; |
| | | } |
| | | |
| | | if (otherSkillActionList.Count > 0) |
| | | if (currentWaitingSkill.Count > 0) |
| | | { |
| | | foreach (var action in otherSkillActionList) |
| | | if (currentWaitingSkill.Any(s => !s.IsFinished())) |
| | | { |
| | | if (!action.IsFinishedForJudge()) return false; |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | if (parentRecordAction != null && parentRecordAction.GetInnerRecordPlayer().IsPlaying()) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | if (isFinished && moveFinished) |
| | |
| | | } |
| | | |
| | | // 检查其他技能动作是否完成 |
| | | if (otherSkillActionList.Count > 0) |
| | | if (currentWaitingSkill.Count > 0) |
| | | { |
| | | for (int i = otherSkillActionList.Count - 1; i >= 0; i--) |
| | | if (currentWaitingSkill.Any(s => s.IsFinished())) |
| | | { |
| | | var action = otherSkillActionList[i]; |
| | | if (action.IsFinished()) |
| | | { |
| | | otherSkillActionList.RemoveAt(i); |
| | | OnSkillFinished(); |
| | | } |
| | | currentWaitingSkill.RemoveAll(s => s.IsFinished()); |
| | | OnSkillFinished(); |
| | | } |
| | | if (otherSkillActionList.Count > 0) |
| | | else |
| | | { |
| | | tempRetValue = false; |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // 检查最终完成状态 |
| | | if (isFinished && moveFinished) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | // 如果自己内部的recora action的 inner record player还有没执行完的包 也是返回false |
| | | if (parentRecordAction != null && parentRecordAction.GetInnerRecordPlayer().IsPlaying()) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | // 技能完全结束,移除技能注册并触发延迟的死亡判定 |
| | | if (battleField != null && caster != null) |
| | | { |
| | | battleField.RemoveCastingSkill(caster.ObjID, this); |
| | | |
| | | // 传递parentRecordAction,让死亡技能等待当前技能完成 |
| | | battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values)); |
| | | DeathRecordAction recordAction = battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values)); |
| | | if (null != recordAction) |
| | | { |
| | | parentRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(recordAction, parentRecordAction, true); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | |
| | | } |
| | | |
| | | // 传递parentRecordAction,让死亡技能等待当前技能完成 |
| | | battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values)); |
| | | RecordAction rc = battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values)); |
| | | if (null != rc) |
| | | { |
| | | parentRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(rc); |
| | | } |
| | | |
| | | // 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(); |
| | | if (currentWaitingSkill.Count > 0) |
| | | { |
| | | foreach (var skill in currentWaitingSkill) |
| | | { |
| | | skill.ForceFinish(); |
| | | } |
| | | currentWaitingSkill.Clear(); |
| | | } |
| | | |
| | | // 3. 清理 DOTween 动画(防止移动回调在战斗结束后执行) |
| | | if (caster != null && caster.heroRectTrans != null) |
| | |
| | | } |
| | | else |
| | | { |
| | | if (pack is CustomB421ActionPack actionPack) |
| | | actionPack.Distribute(); |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | | // 原因:ForceFinished时剩余的包也是技能内部产生的,应该由innerRecordPlayer管理 |
| | | // 这样可以确保即使强制结束,包的处理也在正确的上下文中 |
| | |
| | | } |
| | | |
| | | // 验证其他技能动作是否完成 |
| | | if (otherSkillActionList.Count > 0) |
| | | if (currentWaitingSkill.Count > 0) |
| | | { |
| | | bool hasFinishedAction = false; |
| | | for (int i = otherSkillActionList.Count - 1; i >= 0; i--) |
| | | { |
| | | var action = otherSkillActionList[i]; |
| | | if (action.IsFinished()) |
| | | { |
| | | otherSkillActionList.RemoveAt(i); |
| | | hasFinishedAction = true; |
| | | } |
| | | } |
| | | bool hasFinishedAction = currentWaitingSkill.All(s => s.IsFinished()); |
| | | |
| | | if (hasFinishedAction) |
| | | { |
| | | // 修复死循环:完成后需要清空 currentWaitingSkill |
| | | currentWaitingSkill.Clear(); |
| | | continue; // 使用continue代替递归调用 |
| | | } |
| | | return; |
| | |
| | | |
| | | protected virtual bool ResolvePackList() |
| | | { |
| | | if (currentWaitingSkill.Count > 0) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | while (packList.Count > 0) |
| | | { |
| | | var pack = packList[0]; |
| | | packList.RemoveAt(0); |
| | | |
| | | |
| | | if (pack is CustomHB426CombinePack combinePack && combinePack.startTag.Tag.StartsWith("Skill_")) |
| | | { |
| | | BattleDebug.LogError("other skill casting " + combinePack.startTag.Tag); |
| | | var otherSkillAction = combinePack.CreateSkillAction(); |
| | | otherSkillAction.fromSkill = this; |
| | | otherSkillActionList.Add(otherSkillAction); |
| | | var skillRecordAction = combinePack.CreateSkillAction(); |
| | | skillRecordAction.fromSkill = this; |
| | | currentWaitingSkill.Add(skillRecordAction); |
| | | parentRecordAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction); |
| | | return false; |
| | | } |
| | | else if (IsBuffPack(pack)) |
| | |
| | | buffPackCollections.Clear(); |
| | | continue; |
| | | } |
| | | |
| | | if (pack is CustomB421ActionPack actionPack) |
| | | { |
| | | actionPack.Distribute(); |
| | | } |
| | | else |
| | | { |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | |
| | | { |
| | | tempDropList?.Clear(); |
| | | tempDeadPackList?.Clear(); |
| | | otherSkillActionList?.Clear(); |
| | | currentWaitingSkill?.Clear(); |
| | | dropPackList?.Clear(); |
| | | expPackList?.Clear(); |
| | | buffPackCollections?.Clear(); |