/// <summary> /// 更新,内部调用 /// </summary> public void Fsm_Update() { if (m_Running == false) { return; } OnUpdate(); if (m_Running == false) { return; } if (m_CurState != null) { m_CurState.State_Update(); } else if (m_CurSubFsm != null)//State和SubFsm不会同时存在,注意这里用if和elif是不一样的 { m_CurSubFsm.SubFsm_Update(); } }
/// <summary> /// 更新,内部调用 /// </summary> public void SubFsm_Update() { if (m_Running == false) { return; } OnUpdate(); if (m_Actions != null) { if (m_SequnceAction == false) { foreach (Action ac in m_Actions) { if (!m_Running) { return; } if (ac.Finished == false) { ac.Action_Update(); } } } else { foreach (Action ac in m_Actions) { if (!m_Running) { return; } if (ac.Finished == false) { if (ac.Started == false) { ac.Action_Enter(); } else//Enter和Update隔开一帧,因为Enter可能把它结束了,方便控制状态 { ac.Action_Update(); } break; } } } } if (m_Transitions != null) { foreach (Transition tr in m_Transitions) { if (!m_Running) { return; } if (tr != null && tr.Check()) { MyFsm.ChangeState(tr.NextID); return; } } } if (!m_Running) { return; } if (m_CurState != null) { m_CurState.State_Update(); } else if (m_CurSubFsm != null) { m_CurSubFsm.SubFsm_Update(); } }