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