| | |
| | | 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>(); |
| | | |
| | | protected List<SkillRecordAction> waitingCastSkillRecordAction = new List<SkillRecordAction>(); |
| | | |
| | | |
| | | protected bool moveFinished = false; |
| | | public SkillBase fromSkill; |
| | | public bool isPlay = false; |
| | | |
| | | // 父RecordAction(SkillRecordAction),用于子技能建立父子关系 |
| | | protected RecordAction parentRecordAction; |
| | | protected SkillRecordAction ownRecordAction; |
| | | |
| | | // 技能动画是否播放完成(针对有动画的技能) |
| | | protected bool isMotionCompleted = false; |
| | |
| | | SafetyCheck(); |
| | | } |
| | | |
| | | // 设置父RecordAction |
| | | public void SetParentRecordAction(RecordAction recordAction) |
| | | public virtual void AfterAddToQueue() |
| | | { |
| | | parentRecordAction = recordAction; |
| | | |
| | | } |
| | | |
| | | // 设置父RecordAction |
| | | public void SetOwnRecordAction(SkillRecordAction recordAction) |
| | | { |
| | | ownRecordAction = recordAction; |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | |
| | | var Hurt = tagUseSkillAttack.HurtList[i]; |
| | | BattleObject battleObject = caster.battleField.battleObjMgr.GetBattleObject((int)Hurt.ObjID); |
| | | |
| | | string targetName = battleObject != null ? battleObject.teamHero.name : "Unknown"; |
| | | string targetName = battleObject != null ? battleObject.GetName() : "Unknown"; |
| | | long hurtHp = GeneralDefine.GetFactValue(Hurt.HurtHP, Hurt.HurtHPEx); |
| | | long curHp = GeneralDefine.GetFactValue(Hurt.CurHP, Hurt.CurHPEx); |
| | | |
| | |
| | | var HurtEx = tagUseSkillAttack.HurtListEx[i]; |
| | | BattleObject battleObject = caster.battleField.battleObjMgr.GetBattleObject((int)HurtEx.ObjID); |
| | | |
| | | string targetName = battleObject != null ? battleObject.teamHero.name : "Unknown"; |
| | | string targetName = battleObject != null ? battleObject.GetName() : "Unknown"; |
| | | long hurtHp = GeneralDefine.GetFactValue(HurtEx.HurtHP, HurtEx.HurtHPEx); |
| | | long curHp = GeneralDefine.GetFactValue(HurtEx.CurHP, HurtEx.CurHPEx); |
| | | |
| | |
| | | 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) |
| | |
| | | if (change) |
| | | { |
| | | MoveSpeed = 1125f; |
| | | caster.motionBase.ShowIllusionShadow(true, color); |
| | | caster.ShowIllusionShadow(true, color); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | MoveSpeed = 750f; |
| | | caster.motionBase.ShowIllusionShadow(false); |
| | | caster.ShowIllusionShadow(false); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | // 广播技能释放事件 |
| | | string guid = battleField.guid; |
| | | TeamHero teamHero = caster.teamHero; |
| | | // 获取释放者数据:Hero 传递 teamHero,Mingge 传递 null(因为事件监听器只处理 Hero 数据) |
| | | TeamHero teamHero = null; |
| | | if (caster is HeroBattleObject heroBattleObject) |
| | | { |
| | | teamHero = heroBattleObject.teamHero; |
| | | } |
| | | // 命格释放技能时 teamHero 为 null,监听器会正确处理(已有 null 检查) |
| | | EventBroadcast.Instance.Broadcast<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, guid, skillConfig, teamHero); |
| | | |
| | | if (skillConfig.SkinllSFX1 != 0) |
| | |
| | | { |
| | | if (hintConfig != null) |
| | | { |
| | | battleObject.heroInfoBar.ShowTips(((char)hintConfig.prefix).ToString(), true, false, 1.25f); |
| | | battleObject.ShowTips(((char)hintConfig.prefix).ToString(), true, false, 1.25f); |
| | | } |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | // ShadowIllutionCreate(true); |
| | | MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum), Vector2.zero, () => |
| | | MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.GetPositionNum()), Vector2.zero, () => |
| | | { |
| | | // ShadowIllutionCreate(false); |
| | | OnAttackFinish(); |
| | |
| | | |
| | | ExecuteMoveAndCastSequence(targetTrans, () => |
| | | { |
| | | RectTransform rectTransform = battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum); |
| | | RectTransform rectTransform = battleField.GetTeamNode(caster.Camp, caster.GetPositionNum()); |
| | | // ShadowIllutionCreate(true); |
| | | MoveToTarget(rectTransform, Vector2.zero, () => |
| | | { |
| | |
| | | else |
| | | { |
| | | // ShadowIllutionCreate(true); |
| | | MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum), Vector2.zero, () => |
| | | MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.GetPositionNum()), Vector2.zero, () => |
| | | { |
| | | // ShadowIllutionCreate(false); |
| | | OnAttackFinish(); |
| | |
| | | return; |
| | | } |
| | | |
| | | caster.motionBase.PlayAnimation(MotionName.run, true); |
| | | var tweener = BattleUtility.MoveToTarget(caster.heroRectTrans, target, offset, () => |
| | | caster.PlayAnimation(MotionName.run, true); |
| | | var tweener = BattleUtility.MoveToTarget(caster.GetRectTransform(), target, offset, () => |
| | | { |
| | | caster.motionBase.PlayAnimation(MotionName.idle, true); |
| | | caster.PlayAnimation(MotionName.idle, true); |
| | | _onComplete?.Invoke(); |
| | | }, speed); |
| | | battleField.battleTweenMgr.OnPlayTween(tweener); |
| | |
| | | { |
| | | if (skillConfig.CastDistance < 0) |
| | | { |
| | | Vector3 scale = caster.heroGo.transform.localScale; |
| | | scale.x = Mathf.Abs(scale.x) * forward; |
| | | caster.heroGo.transform.localScale = scale; |
| | | caster.SetFacing(forward); |
| | | } |
| | | _onComplete?.Invoke(); |
| | | } |
| | |
| | | { |
| | | TurnBack(null, 1f); |
| | | OnAllAttackMoveFinished(); |
| | | caster.motionBase.PlayAnimation(MotionName.idle, true); |
| | | caster.PlayAnimation(MotionName.idle, true); |
| | | } |
| | | |
| | | // 所有攻击移动完成后的处理:恢复UI显示状态 |
| | |
| | | foreach (BattleObject bo in allList) |
| | | { |
| | | bo.layerMgr.SetFront(); |
| | | bo.heroInfoBar.SetActive(true); |
| | | bo.GetHeroInfoBar()?.SetActive(true); |
| | | } |
| | | battleField.battleRootNode.skillMaskNode.SetActive(false); |
| | | } |
| | |
| | | // 执行技能释放动画和逻辑:播放施法动作并提供回调 |
| | | protected TrackEntry CastImpl(Action onComplete = null) |
| | | { |
| | | return caster.motionBase.PlaySkillAnimation(skillConfig, this, tagUseSkillAttack.BattleType == 4, onComplete); |
| | | return caster.PlaySkillAnimation(skillConfig, this, tagUseSkillAttack.BattleType == 4, onComplete); |
| | | } |
| | | |
| | | // 技能开始回调:处理死亡、子技能、技能效果初始化 |
| | |
| | | return; |
| | | } |
| | | |
| | | // 先把死亡包收集了 |
| | | HandleDead(); |
| | | |
| | | // 再处理 内嵌技能 |
| | | ProcessSubSkill(); |
| | | |
| | | skillEffect = SkillEffectFactory.CreateSkillEffect(this, caster, skillConfig, tagUseSkillAttack); |
| | | skillEffect.Play(OnHitTargets); |
| | | ProcessSubSkill(); |
| | | HandleWaitingCastSkill(); |
| | | |
| | | |
| | | isPlay = true; |
| | | } |
| | | |
| | | protected void ProcessSubSkill() |
| | | { |
| | | foreach (var subSkillPack in tagUseSkillAttack.subSkillList) |
| | | { |
| | | SkillRecordAction recordAction = CustomHB426CombinePack.CreateSkillAction(battleField.guid, new List<GameNetPackBasic>() { subSkillPack }); |
| | | recordAction.fromSkill = this; |
| | | // 子技能设置WaitingPlay=true,等待父技能动作完成 |
| | | waitingCastSkillRecordAction.Add(recordAction); |
| | | 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; |
| | | // 子技能设置WaitingPlay=true,等待父技能动作完成 |
| | | waitingCastSkillRecordAction.Add(recordAction); |
| | | } |
| | | tagUseSkillAttack.subSkillCombinePackList.Clear(); |
| | | |
| | | waitingCastSkillRecordAction.OrderBy(recordAction => recordAction.hB427_TagSCUseSkill.packUID); |
| | | |
| | | // 按packUID排序所有子技能 |
| | | var allSubSkills = new List<(ulong packUID, SkillRecordAction action)>(); |
| | | |
| | | } |
| | | List<GameNetPackBasic> removePackList = new List<GameNetPackBasic>(); |
| | | |
| | | protected void HandleWaitingCastSkill() |
| | | { |
| | | RecordAction waitingRecordAction = null; |
| | | |
| | | for (int i = 0; i < waitingCastSkillRecordAction.Count; i++) |
| | | foreach (var pack in packList) |
| | | { |
| | | var recordAction = waitingCastSkillRecordAction[i]; |
| | | |
| | | if (waitingRecordAction != null) |
| | | if (pack is HB427_tagSCUseSkill skillPack) |
| | | { |
| | | // 每个都应该等前一个结束后 |
| | | battleField.recordPlayer.ImmediatelyPlay(recordAction, waitingRecordAction, true); |
| | | SkillConfig ssc = SkillConfig.Get((int)skillPack.SkillID); |
| | | if (!string.IsNullOrEmpty(ssc.SkillMotionName)) |
| | | { |
| | | break; |
| | | } |
| | | if (ssc.SkillType == 8) |
| | | { |
| | | 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; |
| | | } |
| | | |
| | | if (ssc.SkillType == 8) |
| | | { |
| | | break; |
| | | } |
| | | |
| | | SkillRecordAction skillRecordAction = combinePack.CreateSkillAction(); |
| | | allSubSkills.Add((sp.packUID, skillRecordAction)); |
| | | removePackList.Add(pack); |
| | | |
| | | if (skillRecordAction.useParentRecordPlayer) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (int i = 0; i < removePackList.Count; i++) |
| | | { |
| | | packList.Remove(removePackList[i]); |
| | | } |
| | | |
| | | // 按packUID排序 |
| | | allSubSkills.Sort((a, b) => a.packUID.CompareTo(b.packUID)); |
| | | |
| | | foreach (var (packUID, recordAction) in allSubSkills) |
| | | { |
| | | if (recordAction.useParentRecordPlayer) |
| | | { |
| | | ownRecordAction.GetInnerRecordPlayer().PlayRecord(recordAction, ownRecordAction); |
| | | } |
| | | else |
| | | { |
| | | battleField.recordPlayer.ImmediatelyPlay(recordAction, parentRecordAction, true); |
| | | } |
| | | |
| | | if (recordAction.IsNeedWaiting()) |
| | | { |
| | | waitingRecordAction = recordAction; |
| | | ownRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(recordAction); |
| | | } |
| | | } |
| | | } |
| | |
| | | var highlightSet = new HashSet<BattleObject>(highlightList); |
| | | |
| | | // 先把施法者的 InfoBar 隐藏(原逻辑保留) |
| | | caster.heroInfoBar.SetActive(false); |
| | | caster.GetHeroInfoBar()?.SetActive(false); |
| | | |
| | | foreach (BattleObject bo in allList) |
| | | { |
| | |
| | | } |
| | | |
| | | // 目标(含 HurtListEx)都应显示 InfoBar |
| | | bo.heroInfoBar.SetActive(isTarget); |
| | | bo.GetHeroInfoBar()?.SetActive(isTarget); |
| | | } |
| | | |
| | | battleField.battleRootNode.skillMaskNode.SetActive(true); |
| | |
| | | // 命中目标回调:处理所有被命中的目标(包括主目标、弹射目标、溅射目标) |
| | | protected virtual void OnHitTargets(int _hitIndex, List<HB427_tagSCUseSkill.tagSCUseSkillHurt> hitList) |
| | | { |
| | | // Debug.LogError($"Skill {skillConfig.SkillID} hit targets _hitIndex: {_hitIndex} hit {string.Join(", ", hitList.Select(h => h.ObjID + ":" + battleField.battleObjMgr.GetBattleObject((int)h.ObjID)?.teamHero.name))}"); |
| | | // Debug.LogError($"Skill {skillConfig.SkillID} hit targets _hitIndex: {_hitIndex} hit {string.Join(", ", hitList.Select(h => h.ObjID + ":" + battleField.battleObjMgr.GetBattleObject((int)h.ObjID)?.GetName()))}"); |
| | | |
| | | // 造成伤害前先处理血量刷新包 |
| | | HandleRefreshHP(); |
| | |
| | | } |
| | | } |
| | | |
| | | 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.GetRectTransform(), battleObject.Camp, |
| | | battleObject.GetModelScale()); |
| | | } |
| | | } |
| | | 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.GetRectTransform(), battleObject.Camp, |
| | | battleObject.GetModelScale()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 处理单个目标被命中:应用伤害和施法者效果 |
| | |
| | | #endif |
| | | |
| | | // 先调用目标受伤 |
| | | target.Hurt(hurtParam, parentRecordAction); |
| | | DeathRecordAction recordAc = target.Hurt(hurtParam, ownRecordAction); |
| | | |
| | | if (null != recordAc) |
| | | { |
| | | tempDeadPackList.Remove(hurtParam.hurter.hurtObj.ObjID); |
| | | ownRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(recordAc, ownRecordAction, true); |
| | | currentWaitingSkill.Add(recordAc); |
| | | } |
| | | |
| | | // 再调用施法者吸血/反伤 |
| | | caster.OnHurtTarget(hurtParam); |
| | |
| | | |
| | | 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.caster.casterObj.GetName()} (ObjID:{hurtParam.caster.casterObj.ObjID})\n" + |
| | | $"目标: {hurtParam.hurter.hurtObj.GetName()} (ObjID:{hurtParam.hurter.hurtObj.ObjID})\n" + |
| | | $"技能: {hurtParam.skillConfig.SkillName} (ID:{hurtParam.skillConfig.SkillID})\n" + |
| | | $"击数: 第{hurtParam.hitIndex + 1}击 / 共{hurtParam.skillConfig.DamageDivide.Length}击" + (isLastHit ? " [最后一击]" : " [中间击]") + "\n" + |
| | | $"\n" + |
| | |
| | | if (refreshPack != null) |
| | | { |
| | | // 分发HP刷新包 |
| | | PackageRegedit.Distribute(refreshPack); |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | | // 原因:HP刷新包是技能内部产生的,应该由当前SkillRecordAction的innerRecordPlayer管理 |
| | | // 这样可以确保HP刷新与技能的生命周期绑定,ForceFinish时一并处理 |
| | | PackageRegeditEx.DistributeToRecordAction(refreshPack, ownRecordAction); |
| | | packList.Remove(refreshPack); |
| | | } |
| | | } |
| | |
| | | List<BattleDeadPack> deadPackList = BattleUtility.FindDeadPack(packList); |
| | | if (deadPackList.Count <= 0) return; |
| | | |
| | | foreach (var deadPack in deadPackList) |
| | | { |
| | | packList.Remove(deadPack.deadPack); |
| | | packList.Remove(deadPack.deadTriggerSkill); |
| | | } |
| | | |
| | | // 找到最大的死亡包 packUID |
| | | BattleDeadPack lastBattleDeadPack = null; |
| | | ulong maxDeathPackUID = 0; |
| | | foreach (var deadPack in deadPackList) |
| | | { |
| | | if (deadPack.deadPack != null && deadPack.deadPack.packUID > maxDeathPackUID) |
| | | { |
| | | maxDeathPackUID = deadPack.deadPack.packUID; |
| | | lastBattleDeadPack = deadPack; |
| | | } |
| | | } |
| | | |
| | | // 如果找到了死亡包,收集所有 packUID > maxDeathPackUID 的包 |
| | | if (maxDeathPackUID > 0 && lastBattleDeadPack != null) |
| | | { |
| | | 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) |
| | | { |
| | | // 排除经验包和掉落包,它们属于当前死亡事件的一部分,不是"死亡后"的包 |
| | | if (pack is HB405_tagMCAddExp expPack && expPack.Source == 2 || |
| | | (pack is H0704_tagRolePackRefresh h0704 && h0704.PackType == (byte)PackType.DropItem && h0704.IsBind == 1)) |
| | | { |
| | | continue; // 跳过经验包和掉落包,让 CheckAfterDeadhPack() 处理它们 |
| | | } |
| | | |
| | | BattleDebug.LogError($"SkillBase.HandleDead: 从packList收集死亡后的包 - Type: {pack.GetType().Name}, UID: {packUID}"); |
| | | lastBattleDeadPack.packListAfterDeath.Add(pack); |
| | | packsToRemove.Add(pack); |
| | | } |
| | | } |
| | | |
| | | packList.RemoveAll(p => packsToRemove.Contains(p)); |
| | | } |
| | | |
| | | CheckAfterDeadhPack(); |
| | | |
| | | // 修复:先收集要删除的包,避免在foreach中修改集合 |
| | | var dropPacksToRemove = new List<H0704_tagRolePackRefresh>(dropPackList); |
| | | foreach (var _dropPack in dropPacksToRemove) |
| | | { |
| | | PackageRegedit.Distribute(_dropPack); |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | | // 原因:掉落包是技能效果的一部分,应该由当前SkillRecordAction管理 |
| | | // 掉落包的分发与技能完成绑定,确保在技能ForceFinish时正确处理 |
| | | PackageRegeditEx.DistributeToRecordAction(_dropPack, ownRecordAction); |
| | | packList.Remove(_dropPack); |
| | | } |
| | | |
| | |
| | | // 构造BattleDrops并缓存 |
| | | for (int i = 0; i < deadPackList.Count; i++) |
| | | { |
| | | BattleDeadPack battleDeadPack = deadPackList[i]; |
| | | int objID = (int)battleDeadPack.deadPack.ObjID; |
| | | BattleDeadPack bdp = deadPackList[i]; |
| | | int objID = (int)bdp.deadPack.ObjID; |
| | | BattleObject deadTarget = battleField.battleObjMgr.GetBattleObject(objID); |
| | | |
| | | // 修复:添加空值检查 |
| | |
| | | |
| | | BattleDrops battleDrops = new BattleDrops() |
| | | { |
| | | rectTransform = deadTarget.heroRectTrans, |
| | | rectTransform = deadTarget.GetRectTransform(), |
| | | dropItemPackIndex = itemIndexList, |
| | | expDrops = expAssign[i] |
| | | }; |
| | |
| | | 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; |
| | | } |
| | | |
| | | // 分配经验值:将经验包平均分配给每个死亡对象 |
| | |
| | | } |
| | | |
| | | |
| | | public virtual bool IsFinishedForJudge() |
| | | public virtual bool IsActionCompleted() |
| | | { |
| | | if (!isPlay) return false; |
| | | |
| | |
| | | if (!skillEffect.IsFinished()) return false; |
| | | } |
| | | |
| | | if (otherSkillActionList.Count > 0) |
| | | if (moveFinished) |
| | | { |
| | | foreach (var action in otherSkillActionList) |
| | | { |
| | | if (!action.IsFinishedForJudge()) return false; |
| | | } |
| | | } |
| | | |
| | | if (isFinished && moveFinished) |
| | | { |
| | | if (packList.Count > 0) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | // 如果技能有动画(SkillMotionName不为空),需要等待动画播放完成 |
| | | if (skillConfig != null && !string.IsNullOrEmpty(skillConfig.SkillMotionName)) |
| | | { |
| | | if (!isMotionCompleted) |
| | | { |
| | | BattleDebug.LogError($"SkillBase.IsFinishedForJudge: 技能 {skillConfig.SkillID} 等待动画播放完成"); |
| | | BattleDebug.LogError($"SkillBase.IsActionCompleted: 技能 {skillConfig.SkillID} 等待动画播放完成"); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | // 检查其他技能动作是否完成 |
| | | 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 (ownRecordAction != null && ownRecordAction.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), null, ownRecordAction); |
| | | if (null != recordAction) |
| | | { |
| | | ownRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(recordAction); |
| | | tempDeadPackList.Clear(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | return !ownRecordAction.GetInnerRecordPlayer().IsPlaying(); |
| | | } |
| | | |
| | | return false; |
| | |
| | | } |
| | | |
| | | // 传递parentRecordAction,让死亡技能等待当前技能完成 |
| | | battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values), parentRecordAction); |
| | | RecordAction rc = battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values)); |
| | | if (null != rc) |
| | | { |
| | | ownRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(rc); |
| | | } |
| | | tempDeadPackList.Clear(); |
| | | |
| | | // 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); |
| | | // 子技能设置WaitingPlay=true,等待父技能动作完成 |
| | | 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); |
| | | // 子技能设置WaitingPlay=true,等待父技能动作完成 |
| | | 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) |
| | | if (caster != null) |
| | | { |
| | | DG.Tweening.DOTween.Kill(caster.heroRectTrans); |
| | | caster.StopMoveAnimation(); |
| | | } |
| | | |
| | | // 4. 重置施法者状态 |
| | | if (caster != null) |
| | | { |
| | | // 重置位置到原点 |
| | | if (caster.heroRectTrans != null) |
| | | { |
| | | caster.heroRectTrans.anchoredPosition = Vector2.zero; |
| | | } |
| | | caster.ResetPosition(); |
| | | |
| | | // 重置朝向 |
| | | if (caster.heroGo != null) |
| | | { |
| | | Vector3 scale = caster.heroGo.transform.localScale; |
| | | scale.x = Mathf.Abs(scale.x); |
| | | caster.heroGo.transform.localScale = scale; |
| | | } |
| | | caster.ResetFacing(); |
| | | |
| | | // 取消幻影效果 |
| | | caster.motionBase?.ShowIllusionShadow(false); |
| | | |
| | | // 播放待机动画(如果还活着) |
| | | if (!caster.teamHero.isDead) |
| | | { |
| | | caster.motionBase?.ResetForReborn(false); |
| | | } |
| | | caster.ShowIllusionShadow(false); |
| | | } |
| | | |
| | | // 5. 恢复 UI 状态 |
| | |
| | | foreach (BattleObject bo in allList) |
| | | { |
| | | bo.layerMgr?.SetFront(); |
| | | bo.heroInfoBar?.SetActive(true); |
| | | bo.GetHeroInfoBar()?.SetActive(true); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | if (pack is CustomB421ActionPack actionPack) |
| | | actionPack.Distribute(); |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | | // 原因:ForceFinished时剩余的包也是技能内部产生的,应该由innerRecordPlayer管理 |
| | | // 这样可以确保即使强制结束,包的处理也在正确的上下文中 |
| | | PackageRegedit.Distribute(pack); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | // 验证其他技能动作是否完成 |
| | | 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); |
| | | |
| | | // 需要给真正parent播的 |
| | | if (skillRecordAction.useParentRecordPlayer && skillRecordAction.parentSkillAction != null) |
| | | { |
| | | skillRecordAction.parentSkillAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction); |
| | | } |
| | | else |
| | | { |
| | | ownRecordAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | else if (IsBuffPack(pack)) |
| | |
| | | buffPackCollections.Clear(); |
| | | continue; |
| | | } |
| | | |
| | | if (pack is CustomB421ActionPack actionPack) |
| | | { |
| | | actionPack.Distribute(); |
| | | } |
| | | else |
| | | { |
| | | PackageRegedit.Distribute(pack); |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | | // 原因:技能执行过程中的包(Buff、属性刷新等)是技能效果的一部分 |
| | | // 应该由SkillRecordAction的innerRecordPlayer管理,确保与技能生命周期一致 |
| | | PackageRegeditEx.DistributeToRecordAction(pack, ownRecordAction); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | tempDropList?.Clear(); |
| | | tempDeadPackList?.Clear(); |
| | | otherSkillActionList?.Clear(); |
| | | currentWaitingSkill?.Clear(); |
| | | dropPackList?.Clear(); |
| | | expPackList?.Clear(); |
| | | buffPackCollections?.Clear(); |
| | |
| | | BattleObject battleObj = battleField.battleObjMgr.GetBattleObject((int)buffRefresh.ObjID); |
| | | if (battleObj != null) |
| | | { |
| | | battleObj.buffMgr.RefreshBuff(buffRefresh, true); |
| | | var buffMgr = battleObj.GetBuffMgr(); |
| | | if (buffMgr != null) // 命格不有 buff 管理器 |
| | | { |
| | | 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); |
| | | var buffMgr = battleObj.GetBuffMgr(); |
| | | if (buffMgr != null) // 命格不有 buff 管理器 |
| | | { |
| | | buffMgr.RemoveBuff(buffDel, false); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | foreach (var pack in buffPacks) |
| | | { |
| | | PackageRegedit.Distribute(pack); |
| | | // 【使用 parentRecordAction.innerRecordPlayer】 |
| | | // 原因:Buff包是技能效果的核心组成部分,应该由SkillRecordAction管理 |
| | | // 即使是强制分发的情况,也要保持在正确的RecordAction上下文中 |
| | | PackageRegeditEx.DistributeToRecordAction(pack, ownRecordAction); |
| | | } |
| | | } |
| | | |