| using UnityEngine; | 
| using System.Collections.Generic; | 
| using Cysharp.Threading.Tasks; | 
|   | 
| public class DeathRecordAction : RecordAction | 
| { | 
|     protected List<HB422_tagMCTurnFightObjDead> deadPackList = new List<HB422_tagMCTurnFightObjDead>(); | 
|   | 
|     public DeathRecordAction(BattleField _battleField, List<HB422_tagMCTurnFightObjDead> _deadPackList) | 
|         : base(RecordActionType.Death, _battleField, null) | 
|     { | 
|         deadPackList = _deadPackList; | 
|     } | 
|   | 
|   | 
|     public override void Run() | 
|     { | 
|         if (isFinish) | 
|         { | 
|             return; | 
|         } | 
|   | 
|         base.Run(); | 
|   | 
|         if (!isRunOnce) | 
|         { | 
|             isRunOnce = true; | 
|             bool isLastOne = false; | 
|             int index = 0; | 
|             int total = deadPackList.Count; | 
|   | 
|             bool canFind = true; | 
|   | 
|             foreach (var deadPack in deadPackList) | 
|             { | 
|                 BattleObject deadObj = battleField.battleObjMgr.GetBattleObject((int)deadPack.ObjID); | 
|                 if (null != deadObj) | 
|                 { | 
|                     deadObj.OnDeath(() => | 
|                     { | 
|                         index++; | 
|   | 
|                         isLastOne = index >= total; | 
|   | 
|                         OnDeathAnimationEnd(deadObj); | 
|   | 
|                         if (isLastOne) | 
|                         { | 
|                             // UniTaskExtension.DelayTime((GameObject)null, 0.3f / battleField.speedRatio, () => | 
|                             // { | 
|                             isFinish = true; | 
|                             // }); | 
|                         } | 
|                     }); | 
|                 } | 
|                 else | 
|                 { | 
|                     canFind = false; | 
|                 } | 
|             } | 
|   | 
|             if (!canFind) | 
|             { | 
|                 isFinish = true; | 
|             } | 
|   | 
|             return; | 
|         } | 
|     } | 
|   | 
|     public override void ForceFinish() | 
|     { | 
|         isFinish = true; | 
|   | 
|         //  直接结束 | 
|         foreach (var deadPack in deadPackList) | 
|         { | 
|             BattleObject deadObj = battleField.battleObjMgr.GetBattleObject((int)deadPack.ObjID); | 
|             if (null != deadObj) | 
|             { | 
|                 OnDeathAnimationEnd(deadObj); | 
|             } | 
|         } | 
|   | 
|         base.ForceFinish(); | 
|     } | 
|   | 
|     private void OnDeathAnimationEnd(BattleObject deadObj) | 
|     { | 
|         //  只有主线掉落物品 | 
|         if (battleField.MapID == 1 || battleField.MapID == 2) | 
|         { | 
|             deadObj.PerformDrop(); | 
|         } | 
|     } | 
| } |