HKMBFZ/Assets/SKFramework/Core/Action/SequenceActionChain.cs

54 lines
1.3 KiB
C#

using UnityEngine;
namespace SK.Framework
{
/// <summary>
/// 序列事件链
/// </summary>
public class SequenceActionChain : AbstractActionChain
{
public SequenceActionChain() : base() { }
public SequenceActionChain(MonoBehaviour executer) : base(executer) { }
protected override void OnInvoke()
{
if(stopWhen != null && stopWhen.Invoke())
{
isCompleted = true;
}
else if (!IsPaused)
{
if (invokeList.Count > 0)
{
if (invokeList[0].Invoke())
{
invokeList.RemoveAt(0);
}
}
isCompleted = invokeList.Count == 0;
}
if (isCompleted)
{
loops--;
if (loops != 0)
{
Reset();
}
else
{
isCompleted = true;
}
}
}
protected override void OnReset()
{
IsPaused = false;
for (int i = 0; i < cacheList.Count; i++)
{
cacheList[i].Reset();
invokeList.Add(cacheList[i]);
}
}
}
}