コード例 #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;
						}
					}
				}
			}
		}
コード例 #2
0
		public StateID GetCurrentState(Transition transition)
		{
			if (transitions.ContainsKey(transition))
				return transitions[transition];
			else
				return new StateID();
		}
コード例 #3
0
		public void DeleteTransition(Transition transition)
		{
			if (transition.Value == Transition.Null)
				Debug.LogError("(ERROR) Finite State Machine: Current transition is set to <null>");
			else if (!transitions.ContainsKey(transition))
				Debug.LogError("(ERROR) Finite State Machine: Transition " + transition.ToString() + " in State " + stateID.ToString() + " does not exist.");
			else
				transitions.Remove(transition);

		}
コード例 #4
0
		public void AddTransition(Transition transition, StateID id)
		{
			if (transition.Value == Transition.Null)
				Debug.LogError("(ERROR) Finite State Machine: Current transition is set to <null>");
			else if (id.Value == StateID.Null)
				Debug.LogError("(ERROR) Finite State Machine: Current transitions id is set to <null>");
			else if (transitions.ContainsKey(transition))
				Debug.LogError("(ERROR) Finite State Machine: State " + stateID.ToString() + " already has transition " + transition.ToString());
			else
				transitions.Add(transition, id);
		}