using UnityEngine;
|
using System.Collections.Generic;
|
|
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)
|
{
|
isFinish = false;
|
deadPackList = _deadPackList;
|
}
|
|
public override bool IsFinished()
|
{
|
return isFinish;
|
}
|
|
|
public override void Run()
|
{
|
base.Run();
|
|
if (!isRunOnce)
|
{
|
isRunOnce = true;
|
bool isLastOne = false;
|
int index = 0;
|
int total = deadPackList.Count;
|
foreach (var deadPack in deadPackList)
|
{
|
index++;
|
isLastOne = index >= total;
|
BattleObject deadObj = battleField.battleObjMgr.GetBattleObject((int)deadPack.ObjID);
|
deadObj.OnDeath(() =>
|
{
|
OnDeathAnimationEnd(deadObj);
|
|
if (isLastOne)
|
{
|
isFinish = true;
|
}
|
});
|
}
|
return;
|
}
|
|
}
|
|
private void OnDeathAnimationEnd(BattleObject deadObj)
|
{
|
// 只有主线掉落物品
|
if (battleField.MapID == 1 || battleField.MapID == 2)
|
{
|
deadObj.PerformDrop();
|
}
|
}
|
|
public override void ForceFinish()
|
{
|
// 设置结束flag 记得清空motionBase里的事件
|
base.ForceFinish();
|
}
|
}
|