From a731fcb2b786b32dd7f0c0e184f7ba58ff44df3f Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期六, 11 十月 2025 14:30:15 +0800
Subject: [PATCH] 0312 优化引导逻辑-存在其他遮罩界面时等待引导

---
 Main/System/Battle/Skill/SkillBase.cs |  236 ++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 155 insertions(+), 81 deletions(-)

diff --git a/Main/System/Battle/Skill/SkillBase.cs b/Main/System/Battle/Skill/SkillBase.cs
index 049ac80..f7009d0 100644
--- a/Main/System/Battle/Skill/SkillBase.cs
+++ b/Main/System/Battle/Skill/SkillBase.cs
@@ -1,9 +1,9 @@
 using System.Collections.Generic;
 using UnityEngine;
-using System;
 using DG.Tweening;
 using Spine;
 using System.Linq;
+using System;
 
 
 public class SkillBase
@@ -14,7 +14,7 @@
 
 	protected HB427_tagSCUseSkill tagUseSkillAttack;
 
-	protected SkillConfig skillConfig;
+	public SkillConfig skillConfig;
 
 	protected bool isFinished = false;
 
@@ -23,12 +23,6 @@
 	protected RectTransform targetNode = null; // 鐩爣鑺傜偣
 
 	protected BattleObject caster = null; // 鏂芥硶鑰�
-
-	protected bool startCounting = false;
-
-	protected bool pauseState = false;
-
-	protected int curFrame = 0;
 
 	protected List<GameNetPackBasic> packList;
 
@@ -40,28 +34,39 @@
 
 	protected bool moveFinished = false;
 
-	public SkillBase(BattleObject _caster, SkillConfig _skillCfg, HB427_tagSCUseSkill vNetData, List<GameNetPackBasic> _packList, BattleField _battleField = null)
+    public int fromSkillId;
+
+	public bool isPlay = false;
+
+    public SkillBase(BattleObject _caster, SkillConfig _skillCfg, HB427_tagSCUseSkill vNetData, List<GameNetPackBasic> _packList, BattleField _battleField = null)
 	{
 		caster = _caster;
+		if (null == caster)
+		{
+			throw new Exception("SkillBase caster is null ");
+		}
 		skillConfig = _skillCfg;
 		tagUseSkillAttack = vNetData;
 		battleField = _battleField;
 		packList = _packList;
 
-		
-
+		// Debug.LogError("start a skill id " + skillConfig.SkillID + " caster " + caster.teamHero.heroId + " pos " + caster.teamHero.positionNum + " camp " + caster.Camp);
 	}
 
 	public virtual void Run()
 	{
-		if (startCounting)
-		{
-			curFrame++;
-		}
-
 		if (null != skillEffect)
 		{
-			skillEffect.Run();
+			if (skillEffect.IsFinished())
+			{
+				skillEffect = null;
+				OnSkillFinished();
+			}
+			else
+			{
+				skillEffect.Run();
+			}
+			return;
 		}
 
 		if (otherSkillAction != null)
@@ -73,30 +78,23 @@
 			}
 			else
 			{
-				otherSkillAction.Run();
+				if (moveFinished)
+				{
+					otherSkillAction.Run();
+				}
 			}
+			return;
 		}
 	}
-
-
-
-	public void Pause()
-	{
-		pauseState = startCounting;
-		startCounting = false;
-	}
-
-	public void Resume()
-	{
-		startCounting = pauseState;
-	}
-
 
 	// 0路绉诲姩鍒拌窛绂荤洰鏍噉鐮侊紝鐨勮窛绂婚噴鏀撅紙鍙厤缃紝9999鍗冲師鍦伴噴鏀撅紝璐熸暟鍒欐槸绉诲姩鍒颁汉鐗╄儗闈紝浜虹墿瑕佽浆韬級
 	// 1路绉诲姩鍒拌窛绂婚樀瀹逛綅缃畁鐮佺殑璺濈锛堝2鍙蜂綅锛�5鍙蜂綅锛夐噴鏀撅紙鍗虫垬鍦轰腑澶绫伙級
 	public virtual void Cast()
 	{
-		EventBroadcast.Instance.Broadcast<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, battleField.guid, skillConfig, caster.teamHero);
+		// Debug.LogError("Cast skill " + skillConfig.SkillID + " cast position " + skillConfig.CastPosition + " cast mode " + skillConfig.castMode); 
+		string guid = battleField.guid;
+		TeamHero teamHero = caster.teamHero;
+		EventBroadcast.Instance.Broadcast<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, guid, skillConfig, teamHero);
 
 		//	楂樹寒鎵�鏈夋湰娆℃妧鑳界浉鍏崇殑鐩爣
 		HighLightAllTargets();
@@ -167,6 +165,8 @@
 			_onComplete?.Invoke();
 		}, speed);
 		battleField.battleTweenMgr.OnPlayTween(tweener);
+
+		// Debug.LogError("move to tarrget " + target.name + " offset " + offset + " speed " + speed + " time " + tweener.Duration());
 	}
 
 	protected void TurnBack(Action _onComplete, float forward)
@@ -249,6 +249,16 @@
 	protected virtual void OnAllAttackMoveFinished()
 	{
 		moveFinished = true;
+		List<BattleObject> allList = battleField.battleObjMgr.allBattleObjDict.Values.ToList<BattleObject>();
+		for (int i = 0; i < allList.Count; i++)
+		{
+			BattleObject bo = allList[i];
+			bo.layerMgr.SetFront();
+			// bo.heroRectTrans.SetParent(battleField.GetTeamNode(bo.Camp, bo.teamHero.positionNum), true);
+			bo.heroInfoBar.SetActive(true);
+		}
+		battleField.battleRootNode.skillMaskNode.SetActive(false);
+		// Debug.LogError("OnAllAttackMoveFinished skill " + skillConfig.SkillID + " cast position " + skillConfig.CastPosition + " cast mode " + skillConfig.castMode); 
 	}
 
 	protected void CastToAllies()
@@ -297,30 +307,29 @@
 		// OnMiddleFrameEnd 涓憞缁撴潫
 		// OnFinalFrameStart 鍚庢憞寮�濮�
 		// OnFinalFrameEnd 鍚庢憞缁撴潫
+
 		return caster.motionBase.PlaySkillAnimation(skillConfig, this, onComplete);
 	}
 
 	//	鎶�鑳藉紑濮�
 	public void OnSkillStart()
 	{
+		HandleDead();
 		skillEffect = SkillEffectFactory.CreateSkillEffect(
 				caster,
 				skillConfig,
 				tagUseSkillAttack
 			);
-		// if (skillEffect != null)
-		{
-			skillEffect.Play(OnHitTargets);
-		}
 
-		
+		skillEffect.Play(OnHitTargets);
+		isPlay = true;
 
 	}
 
 	//	鎶�鑳藉墠鎽囧抚缁撴潫
 	public virtual void OnStartSkillFrameEnd()
 	{
-
+	
 	}
 
 	/// <summary>
@@ -329,18 +338,12 @@
 	/// <param name="times"></param>
 	public virtual void OnMiddleFrameStart(int times)
 	{
-		// if (skillEffect != null)
-		{
-			skillEffect.OnMiddleFrameStart(times);
-		}
+		skillEffect.OnMiddleFrameStart(times);
 	}
 
 	public virtual void OnMiddleFrameEnd(int times, int hitIndex)
 	{
-		// if (skillEffect != null)
-		{
-			skillEffect.OnMiddleFrameEnd(times, hitIndex);
-		}
+		skillEffect.OnMiddleFrameEnd(times, hitIndex);
 	}
 
 	/// <summary>
@@ -348,23 +351,18 @@
 	/// </summary>
 	public virtual void OnFinalFrameStart()
 	{
-		// if (skillEffect != null)
-		{
-			skillEffect.OnFinalFrameStart();
-		}
+		skillEffect.OnFinalFrameStart();
 	}
 
 	/// <summary>
 	/// 鍚庢憞缁撴潫
 	/// </summary>
 	public virtual void OnFinalFrameEnd()
-	{
-		// if (skillEffect != null)
-		{
-			skillEffect.OnFinalFrameEnd();
-		}
+	{	
+		skillEffect.OnFinalFrameEnd();
 
-		HandleDead();
+		//	杞Щ鍒版浜″寘 battleobject.hurt 鏈�鍚庝竴鍑荤殑鏃跺�欐挱鏀�
+		
 	}
 
 
@@ -372,14 +370,21 @@
 
 	protected void HighLightAllTargets()
 	{
+		caster.layerMgr.SetSortingOrder(BattleConst.ActiveHeroActionSortingOrder);
+
 		if (skillConfig.FuncType != 2)
 			return;
 
 		// 楂樹寒鎵�鏈夌洰鏍�
-		List<BattleObject> highlightList = battleField.battleObjMgr.GetBattleObjList(tagUseSkillAttack);
+		List<BattleObject> targetList = battleField.battleObjMgr.GetBattleObjList(tagUseSkillAttack);
+		List<BattleObject> highlightList = new List<BattleObject>(targetList);
 		highlightList.Add(caster);
 
 		List<BattleObject> allList = battleField.battleObjMgr.allBattleObjDict.Values.ToList<BattleObject>();
+
+		caster.heroInfoBar.SetActive(false);
+
+		
 
 		for (int i = 0; i < allList.Count; i++)
 		{
@@ -387,17 +392,28 @@
 			if (highlightList.Contains(bo))
 			{
 				bo.layerMgr.SetFront();
-				bo.heroRectTrans.SetParent(battleField.battleRootNode.skillFrontNode, true);
+				bo.heroInfoBar.SetActive(true);
+				// bo.heroRectTrans.SetParent(battleField.battleRootNode.skillFrontNode, true);
 			}
 			else
 			{
 				bo.layerMgr.SetBack();
-				bo.heroRectTrans.SetParent(battleField.battleRootNode.skillBackNode, true);
+				// bo.heroRectTrans.SetParent(battleField.battleRootNode.skillBackNode, true);
+			}
+
+			if (targetList.Contains(bo))
+			{
+				bo.heroInfoBar.SetActive(true);
+			}
+			else
+			{
+				bo.heroInfoBar.SetActive(false);
 			}
 		}
 
-		battleField.battleRootNode.skillMaskNode.SetActive(true);
 
+		battleField.battleRootNode.skillMaskNode.SetActive(true);
+		battleField.battleRootNode.SetSortingOrder();
 		// caster.battleField.skillMask
 		//	鎶婅繖浜汢O鍏ㄩ珮浜� 鎴栬�呰鎶婇櫎浜嗚繖浜涚殑閮芥斁鍦ㄩ伄缃╁悗闈�
 		//	YYL TODO
@@ -444,13 +460,21 @@
 
 
 		//	TODO YYL AttackTypes  瑕佽〃鐜版垚浠�涔堟牱鍛紵 鏀寔澶氱绫诲瀷骞跺瓨锛屽鏃犺闃插尽涓旀毚鍑诲悓鏃惰鏍兼尅锛屼簩杩涘埗鎴栬繍绠楁渶缁堝�硷紱0-澶辫触锛�1-鏅�氾紱2-鍥炶锛�5-鏍兼尅锛�6-鏃犺闃插尽锛�7-鏆村嚮锛�9-闂伩
-		target.Hurt(damageList, totalDamage, hurt, skillConfig);
+
+
+		int objID = (int)target.ObjID;
+		tempDropList.TryGetValue(objID, out BattleDrops battleDrops);
+		tempDeadPackList.TryGetValue(objID, out HB422_tagMCTurnFightObjDead deadPack);
+		target.Hurt(damageList, totalDamage, hurt, skillConfig, _hitIndex, battleDrops, deadPack);
 
 		//	TODO YYL 杩欓噷鏄鍋氱粺涓�璁$畻鍚庡啀hurt璺焥uckhp杩樻槸鎬庢牱
 		caster.SuckHp(hurt.SuckHP, skillConfig);//	鍚歌
 		caster.HurtByReflect(hurt.BounceHP, skillConfig);// 鍙嶅脊浼ゅ
 	}
 
+	private Dictionary<int, BattleDrops> tempDropList = new Dictionary<int, BattleDrops>();
+
+	private Dictionary<int, HB422_tagMCTurnFightObjDead> tempDeadPackList = new Dictionary<int, HB422_tagMCTurnFightObjDead>();
 
 	protected void HandleDead()
 	{
@@ -499,17 +523,17 @@
 				dropItemPackIndex = itemModelDropsIndexList,
 				expDrops = expAssign[i]
 			};
-			deadTarget.PushDropItems(battleDrops);
+
+			tempDropList.Add((int)deadPackList[i].ObjID, battleDrops);
+			// deadTarget.PushDropItems(battleDrops);
 		}
 
-		// 鍒嗗彂姝讳骸鍖�
-
-		battleField.OnObjsDead(new List<HB422_tagMCTurnFightObjDead>(deadPackList));
+		// battleField.OnObjsDead(new List<HB422_tagMCTurnFightObjDead>(deadPackList));
 		foreach (var deadPack in deadPackList)
 		{
+			tempDeadPackList.Add((int)deadPack.ObjID, deadPack);
 			packList.Remove(deadPack);
 		}
-		deadPackList.Clear();
 	}
 
 
@@ -614,6 +638,11 @@
 	}
 	public virtual bool IsFinished()
 	{
+		if (!isPlay)
+		{
+			return false;
+		}
+
 		if (skillEffect != null)
 		{
 			if (!skillEffect.IsFinished())
@@ -622,23 +651,34 @@
 			}
 			else
 			{
-				OnSkillFinished();
 				skillEffect = null;
+				OnSkillFinished();	
+				return false;		
 			}
 		}
 
+		if (otherSkillAction != null)
+		{
+			if (!otherSkillAction.IsFinished())
+			{
+				return false;
+			}
+			else
+			{
+				otherSkillAction = null;
+				OnSkillFinished();
+				return false;
+			}
+		}
+
+
 		if (isFinished && moveFinished)
 		{
-			List<BattleObject> allList = battleField.battleObjMgr.allBattleObjDict.Values.ToList<BattleObject>();
-			for (int i = 0; i < allList.Count; i++)
+			if (packList.Count > 0)
 			{
-				BattleObject bo = allList[i];
-				bo.layerMgr.SetFront();
-				bo.heroRectTrans.SetParent(battleField.GetTeamNode(bo.Camp, bo.teamHero.positionNum), true);
+				OnSkillFinished();
+				return false;
 			}
-			battleField.battleRootNode.skillMaskNode.SetActive(false);
-
-
 
 			return true;
 		}
@@ -651,26 +691,34 @@
 	public virtual void ForceFinished()
 	{
 		skillEffect?.ForceFinished();
+		if (otherSkillAction != null)
+		{
+			otherSkillAction.ForceFinish();
+			otherSkillAction = null;
+		}
 		isFinished = true;
 		moveFinished = true;
+		isPlay = true;
 
 		while (packList.Count > 0)
 		{
 			var pack = packList[0];
 			packList.RemoveAt(0);
 
-			if (pack is CustomHB426CombinePack)
+			if (pack is CustomHB426CombinePack combinePack)
 			{
-				var combinePack = pack as CustomHB426CombinePack;
 				if (combinePack.startTag.Tag.StartsWith("Skill_"))
 				{
-					BattleDebug.LogError("other skill casting " + combinePack.startTag.Tag);
 					otherSkillAction = combinePack.CreateSkillAction();
-
+					otherSkillAction.fromSkillId = skillConfig.SkillID;
 					//	寮哄埗缁撴潫鍏朵粬鎶�鑳�
 					otherSkillAction.ForceFinish();
-					return;
+					continue;
 				}
+			}
+			else if (pack is CustomB421ActionPack actionPack)
+			{
+				actionPack.Distribute();
 			}
 			PackageRegedit.Distribute(pack);
 		}
@@ -684,6 +732,25 @@
 			{
 				return;
 			}
+			else
+			{
+				skillEffect = null;
+				OnSkillFinished();
+			}
+			
+		}
+
+		if (otherSkillAction != null)
+		{
+			if (!otherSkillAction.IsFinished())
+			{
+				return;
+			}
+			else
+			{
+				otherSkillAction = null;
+				OnSkillFinished();
+			}
 		}
 
 		while (packList.Count > 0)
@@ -698,9 +765,16 @@
 				{
 					BattleDebug.LogError("other skill casting " + combinePack.startTag.Tag);
 					otherSkillAction = combinePack.CreateSkillAction();
+					otherSkillAction.fromSkillId = skillConfig.SkillID;
 					return;
 				}
 			}
+			else if (pack is CustomB421ActionPack actionPack)
+			{
+				actionPack.Distribute();
+			}
+
+			// Debug.LogError("Distribute pack " + pack.GetType().ToString());
 			PackageRegedit.Distribute(pack);
 		}
 

--
Gitblit v1.8.0