/// <summary> /// 删除状态 /// </summary> /// <param name="state"></param> public void DeleteFSMSate(FSMBaseState state) { if (state == null) { return; } if (!mFSMStateDic.ContiansKey(state)) { return; } mFSMStateDic.Remove(state.mStateID); //移除 }
//转换状态 public void TransitionFSMState(FSMTransition transition) { FSMStateID stateID = myState.GetStateIdByTransition(transition); if (stateID != FSMStateID.NullFSMStateID) { myStateID = stateID; myState.StateEnd(); //换状态 myState = myStateDic.FirstOrDefault(q => q.Key == stateID).Value; myState.StateStart(gameObject); } }
public void DeleteFSMState(FSMBaseState state) { if (state == null) { Debug.Log("角色状态为空,无法添加"); return; } if (!myStateDic.ContainsValue(state)) { Debug.Log("容器内不存在该状态"); return; } myStateDic.Remove(state.myStateID); }
/// <summary> /// 添加状态 /// </summary> /// <param name="state"></param> public void AddFSMState(FSMBaseState state) { if (state == null) { return; } if (mCurrentState == null) { mCurrentState = state; mCurrentStateID = state.mStateID; mCurrentState.StateStart(); //启动? } if (mFSMStateDic.ContiansKey(state)) //已经存在 { return; } mFSMStateDic.Add(state.mStateID, state); //添加 }
public void AddFSMState(FSMBaseState state) { if (state == null) { Debug.Log("角色状态为空,无法添加"); return; } if (myState == null) { //第一个添加的状态被作为系统首个运行的状态 myStateID = state.myStateID; myState = state; myState.StateStart(gameObject); } if (myStateDic.ContainsValue(state)) { Debug.Log("容器内存在该状态"); return; } myStateDic.Add(state.myStateID, state); }
public void AddFSMSate(FSMBaseState state) { if (state == null) { Debug.Log("角色状态为空,无法添加"); return; } if (mCurrentState == null) { //第一个添加的状态被作为系统首个运行的状态 mCurrentStateID = state.mStateID; mCurrentState = state; mCurrentState.StateStart(); } if (mFSMStateDic.ContainsValue(state)) { //Debug.Log("容器内存在该状态"); return; } mFSMStateDic.Add(state.mStateID, state); }
//做State的切換 public void PerformTransition(eTransitionID tID, AIData data){ if(tID == eTransitionID.None){ return; } eStateID sID = m_currentState.GetOutputStateID (tID); if (sID == eStateID.None) { return; } m_currentStateID = sID; int iCount = m_State.Count; for (int i = 0; i < iCount; i++) { if (m_State [i].m_StateID == m_currentStateID) { m_currentState.DoBeforeLeave (data); m_currentState = m_State [i]; m_currentState.DoBeforeEnter (data); break; } } }
public void AddState(FSMBaseState state){ if (state == null) { return; } //如果是空的就直接加 int iCount = m_State.Count; if (iCount == 0) { m_State.Add (state); m_currentState = state; m_currentStateID = state.m_StateID; return; } //檢查有無重複 for (int i = 0; i < iCount; i++) { if(m_State[i].m_StateID == state.m_StateID){ return; } } m_State.Add (state); }