using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// 不同效果的trigger继承这个基类
///
public sealed class Trigger
{
public bool Swallow;
private ConditionBase m_Condition;
private List m_ActionChain = new List();
public Trigger(ConditionBase condition, List actions, bool onlyOnce = false, bool swallow = true)
{
Swallow = swallow;
m_Condition = condition;
m_ActionChain.AddRange(actions);
}
public Trigger(ConditionBase condition, ActionBase action, bool onlyOnce = false, bool swallow = true)
{
Swallow = swallow;
m_Condition = condition;
m_ActionChain.Add(action);
}
//重置触发器的参数
public void Reset()
{
}
///
/// 如果触发执行了,返回true,否则返回false
///
///
public bool Update()
{
if (m_Condition.Evaluate())
{
foreach(var action in m_ActionChain)
{
action.Execute();
}
return true;
}
return false;
}
}