/// <summary>检查条件是否达到</summary> public override void Reason(BaseFSM fsm) { base.Reason(fsm); if (patrolComplete) { fsm.ChangeActiveState(FSMTriggerID.PatrolComplete); } }
//条件检测,如果条件符合则进入下一个状态 public virtual void Reason(BaseFSM basefsm) { for (int i = 0; i < triggers.Count; i++) { if (triggers[i].HandleTrigger(basefsm)) { basefsm.ChangeActiveState(triggers[i].triggerid); return; } } }
//4.检查转换条件 public virtual void Reason(BaseFSM fsm) { //检查每一个条件,如果有满足的,则转换状态 for (int i = 0; i < triggers.Count; i++) { if (triggers[i].HandleEvaluate(fsm)) { fsm.ChangeActiveState(triggers[i].triggerId); } } }
/// <summary>条件检测</summary> public void Reason(BaseFSM fsm) { //检测每一个条件对象 for (int i = 0; i < triggers.Count; i++) { //如果有条件达成 if (triggers[i].HandleTrigger(fsm)) { //通知状态机,准备做状态转换 fsm.ChangeActiveState(triggers[i].triggerId); return; } } }
/// <summary> /// 条件检测 /// </summary> public void Reason(BaseFSM fsm) { //?1.如何去将状态和对应条件关联起来 // 状态->条件->状态 //?2.条件列表 //调用条件类当中的HandleTrigger for (int i = 0; i < triggerList.Count; i++) { //检测当前状态对应的条件是否满足 if (triggerList[i].HandleTrigger(fsm)) { //fsm.ChangActiveState() fsm.ChangeActiveState(fsmMap[triggerList[i].triggerID]); } } }