示例#1
0
		public void DoTransition(Transition transition)
		{
			if (transition.Value == Transition.Null)
				Debug.LogError("(ERROR) Finite State Machine: Transition is set to <null>");
			else
			{
				StateID id = currentState.GetCurrentState(transition);
				if (id.Value == StateID.Null)
					Debug.LogError("(ERROR) Finite State Machine: State " + id.ToString() + " does not have target state " + transition.ToString() + " for transition.");
				else
				{
					currentStateID = id;
					foreach(BaseFSMState s in states)
					{
						if (s.ID == currentStateID)
						{
							currentState.DoBeforeLeavingState();
							currentState = s;
							currentState.DoBeforeEnteringState();
							break;
						}
					}
				}
			}
		}