public void DeleteTransition(WolfTransition trans) { if (mMap.ContainsKey(trans) == false) { Debug.LogError("删除转换条件的时候, 转换条件:[" + trans + "]不存在"); return; } mMap.Remove(trans); }
public WolfStateID GetOutPutState(WolfTransition trans) { if (mMap.ContainsKey(trans) == false) { return(WolfStateID.NullState); } else { return(mMap[trans]); } }
public void AddTransition(WolfTransition trans, WolfStateID id) { if (trans == WolfTransition.NullTansition) { Debug.LogError("WolfState Error: trans不能为空"); return; } if (id == WolfStateID.NullState) { Debug.LogError("WolfState Error: 状态ID不能为空"); return; } if (mMap.ContainsKey(trans)) { Debug.LogError("WolfState Error: " + trans + " 已经添加上了"); return; } mMap.Add(trans, id); }
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; } } }