public void DeleteState(BullDemonKingStateID stateID) { if (stateID == BullDemonKingStateID.NullState) { Debug.LogError("要删除的状态ID为空" + stateID); return; } foreach (IBullDemonKingState s in mStates) { if (s.stateID == stateID) { mStates.Remove(s); return; } } Debug.LogError("要删除的SateID不存在集合中:" + stateID); }
public void AddTransition(BullDemonKingTransition trans, BullDemonKingStateID id) { if (trans == BullDemonKingTransition.NullTransition) { Debug.LogError("BullDemonKingState Error: trans不能为空"); return; } if (id == BullDemonKingStateID.NullState) { Debug.LogError("BullDemonKingState Error: 状态ID不能为空"); return; } if (mMap.ContainsKey(trans)) { Debug.LogError("BullDemonKingState Error: " + trans + " 已经添加上了"); return; } mMap.Add(trans, id); }
public void PerformTransition(BullDemonKingTransition trans) { if (trans == BullDemonKingTransition.NullTransition) { Debug.LogError("要执行的转换条件为空:" + trans); return; } BullDemonKingStateID nextStateID = mCurrentState.GetOutPutState(trans); if (nextStateID == BullDemonKingStateID.NullState) { Debug.LogError("在转换条件[" + trans + "]下,没有对应的转换状态"); return; } foreach (IBullDemonKingState s in mStates) { if (s.stateID == nextStateID) { mCurrentState.DoBeforeLeaving(); mCurrentState = s; mCurrentState.DoBeforeEntering(); return; } } }