| | |
| | | |
| | | protected Dictionary<int, bool> dropStateDict = new Dictionary<int, bool>(); |
| | | |
| | | public DeathRecordAction(BattleField _battleField, List<BattleDeadPack> _deadPackList) |
| | | protected RecordAction causingRecordAction = null; |
| | | |
| | | protected bool hasDeathTriggerSkill = false; |
| | | |
| | | public DeathRecordAction(BattleField _battleField, List<BattleDeadPack> _deadPackList, RecordAction _causingRecordAction = null) |
| | | : base(RecordActionType.Death, _battleField, null) |
| | | { |
| | | deadPackList = _deadPackList; |
| | | causingRecordAction = _causingRecordAction; |
| | | CheckHasDeathTriggerSkill(); |
| | | } |
| | | |
| | | protected void CheckHasDeathTriggerSkill() |
| | | { |
| | | foreach (var battleDeadPack in deadPackList) |
| | | { |
| | | if (battleDeadPack.deadTriggerSkill != null) |
| | | { |
| | | hasDeathTriggerSkill = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | if (null != skillAction) |
| | | { |
| | | deathActionDict.Add(battleDeadPack, skillAction); |
| | | // 死亡触发技能都设置WaitingPlay=true,等待父节点动作完成 |
| | | // 如果DeathRecordAction有父节点(导致死亡的技能),则等待那个父节点 |
| | | // 否则等待DeathRecordAction本身 |
| | | battleField.recordPlayer.ImmediatelyPlay(skillAction, causingRecordAction == null ? this : causingRecordAction, true); |
| | | } |
| | | } |
| | | else |
| | |
| | | deathActionDict.Remove(key); |
| | | } |
| | | |
| | | if (0 == deathActionDict.Count) |
| | | { |
| | | hasDeathTriggerSkill = false; |
| | | } |
| | | |
| | | int completeNum = 0; |
| | | |
| | | foreach (var kv in deadActionStatesDict) |
| | |
| | | |
| | | if (completeNum == deadPackList.Count) |
| | | { |
| | | isActionCompleted = true; |
| | | isFinish = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // 重写IsActionCompleted,死亡动作是否完成 |
| | | public override bool IsActionCompleted() |
| | | { |
| | | return isActionCompleted || isFinish; |
| | | } |
| | | |
| | | private Func<bool> CreateDeadActionState(BattleDeadPack deadPack, bool withoutAnime = false) |
| | |
| | | deadObj.PerformDrop(); |
| | | } |
| | | } |
| | | |
| | | protected bool HasDeathTriggerSkill() |
| | | { |
| | | return hasDeathTriggerSkill; |
| | | } |
| | | |
| | | public override bool CanStartExecution() |
| | | { |
| | | // 如果不是WaitingPlay模式,直接可以执行 |
| | | if (!isWaitingPlay) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | // 如果没有父节点,也可以执行 |
| | | if (parentAction == null) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | // 可以先执行没有死亡触发技能的死亡动作 |
| | | if (!HasDeathTriggerSkill()) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | // WaitingPlay模式下,需要等待直接父节点的动作完成(不管父节点是否WaitingPlay) |
| | | if (!parentAction.IsActionCompleted()) |
| | | { |
| | | BattleDebug.LogError($"RecordAction.CanStartExecution: {this.GetType().Name} 等待父节点 {parentAction.GetType().Name} 动作完成"); |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | } |