From 99a11d2bb19d74f6cc8584ac16838062af4fb301 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 03 四月 2026 11:24:07 +0800
Subject: [PATCH] webgl 优化

---
 Main/System/Battle/Skill/SkillBase.cs |   86 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 69 insertions(+), 17 deletions(-)

diff --git a/Main/System/Battle/Skill/SkillBase.cs b/Main/System/Battle/Skill/SkillBase.cs
index ba8647d..83da046 100644
--- a/Main/System/Battle/Skill/SkillBase.cs
+++ b/Main/System/Battle/Skill/SkillBase.cs
@@ -195,7 +195,7 @@
         
     }
 
-    // 鎶�鑳借繍琛屼富閫昏緫锛氬鐞嗘妧鑳芥晥鏋滃拰鍏朵粬鎶�鑳藉姩浣�
+    // 鎶�鑳借繍琛屼富閫昏緫锛氫粎椹卞姩鎶�鑳芥晥鏋滐紙skillEffect锛夛紝瀛愭妧鑳藉拰姝讳骸鐢盜sFinished()鎺ㄨ繘
     public virtual void Run()
     {
         if (skillEffect != null)
@@ -211,8 +211,6 @@
             }
             return;
         }
-
-
     }
 
     protected void ShadowIllutionCreate(bool create)
@@ -370,7 +368,7 @@
             return;
         }
 
-        int mainTargetPosNum = BattleUtility.GetMainTargetPositionNum(this, caster, tagUseSkillAttack.HurtList.ToList(), skillConfig);
+        int mainTargetPosNum = BattleUtility.GetMainTargetPositionNum(this, caster, tagUseSkillAttack.HurtList, skillConfig);
         BattleCamp battleCamp = skillConfig.TagFriendly != 0 ? caster.Camp : caster.GetEnemyCamp();
         RectTransform targetTrans = battleField.GetTeamNode(battleCamp, mainTargetPosNum);
 
@@ -482,9 +480,9 @@
     protected virtual void OnAllAttackMoveFinished()
     {
         moveFinished = true;
-        List<BattleObject> allList = battleField.battleObjMgr.allBattleObjDict.Values.ToList<BattleObject>();
-        foreach (BattleObject bo in allList)
+        foreach (var kv in battleField.battleObjMgr.allBattleObjDict)
         {
+            BattleObject bo = kv.Value;
             bo.layerMgr.SetFront();
             bo.GetHeroInfoBar()?.SetActive(true);
         }
@@ -672,7 +670,7 @@
         // 纭繚鏂芥硶鑰呬篃琚珮浜紙鍘熼�昏緫锛�
         var highlightList = new List<BattleObject>(targetSet) { caster };
 
-        var allList = battleField.battleObjMgr.allBattleObjDict.Values.ToList();
+        var allList = battleField.battleObjMgr.allBattleObjDict.Values;
 
         // 鏋勯�犻泦鍚堜究浜庡垽鏂�
         var targetSetLookup = new HashSet<BattleObject>(targetSet);
@@ -1022,7 +1020,12 @@
         // 鑾峰彇骞跺垎閰嶆帀钀界墿鍝佸拰缁忛獙
         var dropPack = PackManager.Instance.GetSinglePack(PackType.DropItem);
         var itemDict = dropPack.GetAllItems();
-        List<ItemModel> itemList = new List<ItemModel>(itemDict.Values.Where(item => item != null && item.isAuction));
+        List<ItemModel> itemList = new List<ItemModel>();
+        foreach (var item in itemDict.Values)
+        {
+            if (item != null && item.isAuction)
+                itemList.Add(item);
+        }
 
         var dropAssign = AssignDrops(itemList, deadPackList.Count);
         var expAssign = AssignExp(expPackList, deadPackList.Count);
@@ -1041,7 +1044,9 @@
                 continue;
             }
             
-            List<int> itemIndexList = dropAssign[i].Select(item => item.gridIndex).ToList();
+            List<int> itemIndexList = new List<int>(dropAssign[i].Count);
+            for (int j = 0; j < dropAssign[i].Count; j++)
+                itemIndexList.Add(dropAssign[i][j].gridIndex);
             
             BattleDrops battleDrops = new BattleDrops()
             {
@@ -1238,7 +1243,8 @@
         return false;
     }
 
-    // 妫�鏌ユ妧鑳芥槸鍚﹀畬鎴愶細缁煎悎妫�鏌ユ墍鏈夊畬鎴愭潯浠�
+    // 妫�鏌ユ妧鑳芥槸鍚﹀畬鎴愶細鍚屾椂鎺ㄨ繘鐘舵�侊紙娓呯悊瀹屾垚鐨勫瓙鎶�鑳姐�佸鐞嗗墿浣欏寘銆佽Е鍙戞浜″垽瀹氾級
+    // 娉ㄦ剰锛氭鏂规硶鏈夊壇浣滅敤锛岃繖鏄璁′娇鐒垛�斺�旂敱SkillRecordAction.Run()姣忓抚璋冪敤鏉ラ┍鍔ㄧ姸鎬佹帹杩�
     public virtual bool IsFinished()
     {
         if (!isPlay) return false;
@@ -1254,7 +1260,7 @@
             tempRetValue = false;
         }
 
-        // 妫�鏌ュ叾浠栨妧鑳藉姩浣滄槸鍚﹀畬鎴�
+        // 妫�鏌ヨ窡杩涚殑鎶�鑳藉姩浣滄槸鍚﹀畬鎴愶紙杩藉嚮/杩炲嚮/鍙嶅嚮绛夛級
         if (currentWaitingSkill.Count > 0)
         {
             if (currentWaitingSkill.Any(s => s.IsFinished()))
@@ -1273,7 +1279,6 @@
             return false;
         }
 
-
         // 妫�鏌ユ渶缁堝畬鎴愮姸鎬�
         if (isFinished && moveFinished)
         {
@@ -1283,7 +1288,7 @@
                 return false;
             }
 
-            //  濡傛灉鑷繁鍐呴儴鐨剅ecora action鐨� inner record player杩樻湁娌℃墽琛屽畬鐨勫寘 涔熸槸杩斿洖false
+            //  濡傛灉鑷繁鍐呴儴鐨� innerRecordPlayer 杩樻湁娌℃墽琛屽畬鐨勫寘 涔熸槸杩斿洖false
             if (ownRecordAction != null && ownRecordAction.GetInnerRecordPlayer().IsPlaying())
             {
                 return false;
@@ -1294,7 +1299,6 @@
             {
                 battleField.RemoveCastingSkill(caster.ObjID, this);
                 
-                //  浼犻�抪arentRecordAction锛岃姝讳骸鎶�鑳界瓑寰呭綋鍓嶆妧鑳藉畬鎴�
                 DeathRecordAction recordAction = battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values), null, ownRecordAction);
                 if (null != recordAction)
                 {
@@ -1362,6 +1366,12 @@
 
             // 鍙栨秷骞诲奖鏁堟灉
             caster.ShowIllusionShadow(false);
+
+            // 閲嶇疆MotionBase鐨勬妧鑳藉姩鐢荤姸鎬侊紝闃叉playingSkillWithAnim鍗′綇鍚庣画鎶�鑳�
+            if (caster is HeroBattleObject heroCaster)
+            {
+                heroCaster.ForceResetMotionSkillState();
+            }
         }
 
         // 5. 鎭㈠ UI 鐘舵��
@@ -1490,14 +1500,22 @@
                 skillRecordAction.fromSkill = this;
                 currentWaitingSkill.Add(skillRecordAction);
 
-                //  闇�瑕佺粰鐪熸parent鎾殑
+                //  鏍规嵁鍚庣画鎶�鑳界殑灞炴�у喅瀹氭槸鍚﹂渶瑕佺瓑寰呭綋鍓嶆妧鑳藉綊浣�
+                RecordAction waitAction = GetFollowUpWaitAction(skillRecordAction);
+
                 if (skillRecordAction.useParentRecordPlayer && skillRecordAction.parentSkillAction != null)
                 {
-                    skillRecordAction.parentSkillAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction);
+                    if (waitAction != null)
+                        skillRecordAction.parentSkillAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction, waitAction);
+                    else
+                        skillRecordAction.parentSkillAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction);
                 }
                 else
                 {
-                    ownRecordAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction);
+                    if (waitAction != null)
+                        ownRecordAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction, waitAction);
+                    else
+                        ownRecordAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction);
                 }
 
                 return false;
@@ -1539,6 +1557,40 @@
         return true;
     }
 
+    /// <summary>
+    /// 鍒ゅ畾鍚庣画鎶�鑳斤紙杩藉嚮/杩炲嚮/鍙嶅嚮绛夛級鏄惁闇�瑕佺瓑寰呭綋鍓嶆妧鑳藉畬鎴愬姩浣滃悗鍐嶉噴鏀�
+    /// 缁煎悎鍒ゅ埆锛氭妧鑳芥槸鍚︽湁鍔ㄧ敾銆侀噴鏀炬ā寮忔槸鍚﹂渶瑕佷綅绉汇�佹槸鍚﹀悓涓�鏂芥硶鑰�
+    /// 浠呭湪纭瀹夊叏鏃惰繑鍥瀢aitAction锛岄伩鍏嶄笉蹇呰鐨勭瓑寰呭拰娼滃湪鐨勮法瑙掕壊鐩镐簰绛夊緟
+    /// </summary>
+    private RecordAction GetFollowUpWaitAction(SkillRecordAction followUp)
+    {
+        // 褰撳墠鎶�鑳藉凡缁忓綊浣嶏紝鏃犻渶绛夊緟
+        if (moveFinished) return null;
+
+        if (followUp.skillBase == null) return null;
+
+        // 鍚庣画鎶�鑳芥病鏈夊姩鐢诲姩浣滐紙鏃燬killMotionName锛夛紝涓嶆秹鍙婁綅绉伙紝鏃犻渶绛夊緟褰掍綅
+        // 杩欑被鎶�鑳藉湪CanCastSkill涓篃涓嶅彈playingSkillWithAnim闄愬埗
+        var followUpSkin = followUp.skillBase.skillSkinConfig;
+        if (followUpSkin == null || string.IsNullOrEmpty(followUpSkin.SkillMotionName))
+            return null;
+
+        // 鍚庣画鎶�鑳藉師鍦伴噴鏀撅紙None/Self锛夛紝铏芥湁鍔ㄧ敾浣嗕笉闇�瑕佷綅绉诲埌鐩爣锛屾棤闇�绛夊緟
+        if (followUpSkin.castMode == SkillCastMode.None || followUpSkin.castMode == SkillCastMode.Self)
+            return null;
+
+        // 鍚屼竴鏂芥硶鑰呯殑鍚庣画鎶�鑳斤紙杩炲嚮绛夛級锛氬繀椤荤瓑寰呭綊浣�
+        // 鍘熷洜锛氬悓涓�瑙掕壊鐨凜astToEnemy/CastToTarget浼歁oveToTarget锛�
+        // 濡傛灉涓婁竴涓妧鑳界殑DOTween褰掍綅杩樻病瀹屾垚灏卞彂璧锋柊浣嶇Щ锛屼袱涓狣OTween浼氬啿绐�
+        if (followUp.skillBase.caster == caster)
+            return ownRecordAction;
+
+        // 涓嶅悓鏂芥硶鑰呯殑鍚庣画鎶�鑳斤紙杩藉嚮/鍙嶅嚮绛夛級锛氫笉娣诲姞绛夊緟
+        // 鍘熷洜锛氫笉鍚岃鑹蹭粠鍚勮嚜浣嶇疆鍑哄彂锛屼笉瀛樺湪DOTween鍐茬獊
+        // 娉ㄦ剰锛氭澶勪笉娣诲姞璺ㄨ鑹茬瓑寰呭叧绯伙紝閬垮厤鎶�鑳介摼A绛塀銆丅绛堿鐨勭浉浜掔瓑寰呴闄�
+        return null;
+    }
+
     // 娣诲姞娓呯悊鏂规硶锛氶槻姝㈠唴瀛樻硠婕�
     public virtual void Cleanup()
     {

--
Gitblit v1.8.0