From 61b188e1d59af9a1e3b4f005bd4b9211b2db97d8 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 09 十月 2025 15:46:31 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts

---
 Main/System/Battle/Skill/SkillBase.cs |  257 +++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 185 insertions(+), 72 deletions(-)

diff --git a/Main/System/Battle/Skill/SkillBase.cs b/Main/System/Battle/Skill/SkillBase.cs
index f51ffe4..a10eec9 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,40 @@
 
 	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 +79,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();
@@ -151,12 +150,12 @@
 		// battleField.battleTweenMgr.OnPlayTween(tweener);
 	}
 
-	protected void MoveToTarget(RectTransform target, Vector2 offset, Action onComplete = null)
+	protected void MoveToTarget(RectTransform target, Vector2 offset, Action _onComplete = null, float speed = 500f)
 	{
 		//	鍘熷湴閲婃斁
 		if (skillConfig.CastDistance >= 9999)
 		{
-			onComplete?.Invoke();
+			_onComplete?.Invoke();
 			return;
 		}
 
@@ -164,9 +163,11 @@
 		var tweener = BattleUtility.MoveToTarget(caster.heroRectTrans, target, offset, () =>
 		{
 			caster.motionBase.PlayAnimation(MotionName.idle, true);
-			onComplete?.Invoke();
-		});
+			_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)
@@ -199,7 +200,7 @@
 						{
 							//	鍥炲埌鍘熸潵鐨勪綅缃�
 							MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum), Vector2.zero, 
-								OnAttackFinish);
+								OnAttackFinish, 750F);
 						}
 					, -1f);
 				});
@@ -236,9 +237,9 @@
 					TurnBack(
 						() =>
 						{
+							RectTransform rectTransform = battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum);
 							//	鍥炲埌鍘熸潵鐨勪綅缃�
-							MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum), Vector2.zero, 
-								OnAttackFinish);
+							MoveToTarget(rectTransform, Vector2.zero, OnAttackFinish, 750F);
 						}
 					, -1f);
 				});
@@ -249,6 +250,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()
@@ -268,7 +279,7 @@
 						{
 							//	鍥炲埌鍘熸潵鐨勪綅缃�
 							MoveToTarget(battleField.GetTeamNode(caster.Camp, caster.teamHero.positionNum),
-								Vector2.zero, OnAttackFinish);
+								Vector2.zero, OnAttackFinish, 750F);
 						}
 					, -1f);
 				});
@@ -297,6 +308,7 @@
 		// OnMiddleFrameEnd 涓憞缁撴潫
 		// OnFinalFrameStart 鍚庢憞寮�濮�
 		// OnFinalFrameEnd 鍚庢憞缁撴潫
+
 		return caster.motionBase.PlaySkillAnimation(skillConfig, this, onComplete);
 	}
 
@@ -308,19 +320,16 @@
 				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,21 +351,15 @@
 	/// </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();
 	}
@@ -372,11 +369,51 @@
 
 	protected void HighLightAllTargets()
 	{
+		caster.layerMgr.SetSortingOrder(BattleConst.ActiveHeroActionSortingOrder);
+
+		if (skillConfig.FuncType != 2)
+			return;
+
 		// 楂樹寒鎵�鏈夌洰鏍�
-		HashSet<BattleObject> highlightList = new HashSet<BattleObject>(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++)
+		{
+			BattleObject bo = allList[i];
+			if (highlightList.Contains(bo))
+			{
+				bo.layerMgr.SetFront();
+				bo.heroInfoBar.SetActive(true);
+				// bo.heroRectTrans.SetParent(battleField.battleRootNode.skillFrontNode, true);
+			}
+			else
+			{
+				bo.layerMgr.SetBack();
+				// 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.SetSortingOrder();
+		// caster.battleField.skillMask
 		//	鎶婅繖浜汢O鍏ㄩ珮浜� 鎴栬�呰鎶婇櫎浜嗚繖浜涚殑閮芥斁鍦ㄩ伄缃╁悗闈�
 		//	YYL TODO
 	}
@@ -404,6 +441,8 @@
 	protected virtual void OnHitEachTarget(int _hitIndex, BattleObject target, HB427_tagSCUseSkill.tagSCUseSkillHurt hurt)
 	{
 		// 浼ゅ鍒嗗竷 (涓囧垎姣�)
+		// Debug.LogError("skillConfig.DamageDivide.Count " + skillConfig.DamageDivide.Length + " _hitIndex " + _hitIndex);
+		bool isLastHit = _hitIndex >= skillConfig.DamageDivide.Length - 1;
 		int[] damageDivide = skillConfig.DamageDivide[_hitIndex];
 
 		long totalDamage = GeneralDefine.GetFactValue(hurt.HurtHP, hurt.HurtHPEx);
@@ -421,7 +460,12 @@
 
 
 		//	TODO YYL AttackTypes  瑕佽〃鐜版垚浠�涔堟牱鍛紵 鏀寔澶氱绫诲瀷骞跺瓨锛屽鏃犺闃插尽涓旀毚鍑诲悓鏃惰鏍兼尅锛屼簩杩涘埗鎴栬繍绠楁渶缁堝�硷紱0-澶辫触锛�1-鏅�氾紱2-鍥炶锛�5-鏍兼尅锛�6-鏃犺闃插尽锛�7-鏆村嚮锛�9-闂伩
-		target.Hurt(damageList, totalDamage, hurt, skillConfig);
+
+		List<HB422_tagMCTurnFightObjDead> deadPacks = BattleUtility.FindDeadPack(packList);
+		bool isTargetDead = deadPacks.Exists(p => p.ObjID == target.ObjID);
+
+		bool playAnimation = !(isLastHit && isTargetDead);
+		target.Hurt(damageList, totalDamage, hurt, skillConfig, playAnimation);
 
 		//	TODO YYL 杩欓噷鏄鍋氱粺涓�璁$畻鍚庡啀hurt璺焥uckhp杩樻槸鎬庢牱
 		caster.SuckHp(hurt.SuckHP, skillConfig);//	鍚歌
@@ -591,6 +635,11 @@
 	}
 	public virtual bool IsFinished()
 	{
+		if (!isPlay)
+		{
+			return false;
+		}
+
 		if (skillEffect != null)
 		{
 			if (!skillEffect.IsFinished())
@@ -599,37 +648,75 @@
 			}
 			else
 			{
-				OnSkillFinished();
 				skillEffect = null;
+				OnSkillFinished();	
+				return false;		
 			}
 		}
 
-		return isFinished && moveFinished;
+		if (otherSkillAction != null)
+		{
+			if (!otherSkillAction.IsFinished())
+			{
+				return false;
+			}
+			else
+			{
+				otherSkillAction = null;
+				OnSkillFinished();
+				return false;
+			}
+		}
+
+
+		if (isFinished && moveFinished)
+		{
+			if (packList.Count > 0)
+			{
+				OnSkillFinished();
+				return false;
+			}
+
+			return true;
+		}
+		else
+		{
+			return false;
+		}
 	}
 
 	public virtual void ForceFinished()
 	{
 		skillEffect?.ForceFinished();
+		if (otherSkillAction != null)
+		{
+			otherSkillAction.ForceFinish();
+			otherSkillAction = null;
+		}
+		HandleDead();
 		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);
 		}
@@ -643,6 +730,25 @@
 			{
 				return;
 			}
+			else
+			{
+				skillEffect = null;
+				OnSkillFinished();
+			}
+			
+		}
+
+		if (otherSkillAction != null)
+		{
+			if (!otherSkillAction.IsFinished())
+			{
+				return;
+			}
+			else
+			{
+				otherSkillAction = null;
+				OnSkillFinished();
+			}
 		}
 
 		while (packList.Count > 0)
@@ -657,9 +763,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