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