public void PerformTrnsition(SoldierTransition trans) { if (trans == SoldierTransition.NullTansition) { Debug.LogError(GetType() + "/PerformTrnsition()/ trans is NullTansition "); return; } SoldierStateID nextStateId = mCurState.GetOutputState(trans); if (nextStateId == SoldierStateID.NullState) { Debug.LogError(GetType() + "/PerformTrnsition()/ stateId is NullState "); return; } foreach (ISoldierState s in mStateLst) { if (s.StateID == nextStateId) { mCurState.DoBeforeLeaving(); mCurState = s; mCurState.DoBeforeEntering(); } } }
public void AddState(ISoldierState state) { if (state == null) { Debug.LogError(GetType() + "/AddState()/ state is null "); return; } if (mStateLst.Count == 0) { mStateLst.Add(state); mCurState = state; return; } foreach (ISoldierState s in mStateLst) { if (s.StateID == state.StateID) { Debug.LogError(GetType() + "/AddState()/ state had been contained : " + state); return; } } mStateLst.Add(state); }