public void PerformTransition(WolfTransition trans) { if (trans == WolfTransition.NullTansition) { Debug.LogError("要执行的转换条件为空 : " + trans); return; } WolfStateID nextStateID = mCurrentState.GetOutPutState(trans); if (nextStateID == WolfStateID.NullState) { Debug.LogError("在转换条件 [" + trans + "] 下,没有对应的转换状态"); return; } foreach (IWolfState s in mStates) { if (s.stateID == nextStateID) { mCurrentState.DoBeforeLeaving(); mCurrentState = s; mCurrentState.DoBeforeEntering(); return; } } }
public void AddState(IWolfState state) { if (state == null) { Debug.LogError("要添加的状态为空"); return; } if (mStates.Count == 0) { mStates.Add(state); mCurrentState = state; mCurrentState.DoBeforeEntering(); return; } foreach (IWolfState s in mStates) { if (s.stateID == state.stateID) { Debug.LogError("要添加的状态ID[" + s.stateID + "]已经添加"); return; } } mStates.Add(state); }